Skip to main content

Prerequisites

Before making API calls, please ensure you have obtained the following credentials:

Base URL

API Endpoint, formatted as: https://api.onetoken.one

API Key

The token generated in the OneToken dashboard, formatted as: sk-xxxxxxxxxxxx

1. Text to Image API

This endpoint is used to generate a brand-new image from scratch based on the text prompt you provide.

Request Information

POST
/v1/images/generations/
required
Standard OpenAI-compatible image generation path.

Request Format

application/json

Request Parameters

model
string
required
Must be set to gpt-image-2.
prompt
string
required
A description of the desired image, supported in both English and Chinese.
n
integer
default:"1"
The number of images to generate.
size
string
default:"1024x1024"
The resolution of the image, e.g., 1024x1024 or 512x512.
quality
string
default:""
The quality of the image that will be generated.

Code Examples

curl [https://api.onetoken.one/v1/images/generations/](https://api.onetoken.one/v1/images/generations/) \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A futuristic city with flying cars at sunset, cyberpunk style, highly detailed",
    "n": 1,
    "size": "1024x1024"
  }'


2. Image Edits API

This endpoint is used to modify an existing image. You need to provide an original image and a mask image (transparent areas in the mask image indicate parts that need to be modified/replaced).

Request Information

Request Format

multipart/form-data

Request Parameters

Code Examples

curl -X POST "[https://api.onetoken.one/v1/images/edits/](https://api.onetoken.one/v1/images/edits/)" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx" \
  -F image="cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.png" \
  -F prompt="A cute baby sea otter wearing a beret."


3. Response Data Structure

Upon a successful API call, a JSON object containing the image data will be returned.

Success Response Example

{
  "created": 1718112345,
  "data": [
    {
      // Depending on the response_format field
      // "url": "[https://cdn.your-domain.com/images/abc123xyz.png](https://cdn.your-domain.com/images/abc123xyz.png)",
      "b64_json": "xxx"
    }
  ]
}