Prerequisites
Before making API calls, please ensure you have obtained the following credentials:Base URL
API Endpoint, formatted as:
https://api.onetoken.oneAPI Key
The token generated in the OneToken dashboard, formatted as:
sk-xxxxxxxxxxxx1. 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
/v1/images/generations/
required
Standard OpenAI-compatible image generation path.
Request Format
application/jsonRequest Parameters
string
required
Must be set to
gpt-image-2.string
required
A description of the desired image, supported in both English and Chinese.
integer
default:"1"
The number of images to generate.
string
default:"1024x1024"
The resolution of the image, e.g.,
1024x1024 or 512x512.string
default:""
The quality of the image that will be generated.
low medium high autoCode Examples
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
/v1/images/edits/
required
Standard OpenAI-compatible image editing path.
Request Format
multipart/form-dataRequest Parameters
string
required
Must be set to
gpt-image-2.string
required
A description of the desired image. Both English and Chinese are supported.
integer
default:"1"
The number of images to generate.
string
default:"1024x1024"
The image resolution, such as
1024x1024 or 512x512.string
default:"b64_json"
The response format for generated images. Must be
url or b64_json.file
default:""
The images to edit. You can provide up to 16 images.
Code Examples
3. Response Data Structure
Upon a successful API call, a JSON object containing the image data will be returned.Success Response Example
4. Common Sizes
- Square and Near-Square Ratios
- Traditional Classic Aspect Ratios
- Widescreen and Ultrawide Aspect Ratios

