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

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

Request Format

application/json

Request 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 auto

Code 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-data

Request 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

  1. Square and Near-Square Ratios
1:1 1K: 1024 × 1024 2K: 2048 × 2048 4K: 4096 × 4096 5:4 1K: 1280 × 1024 2K: 2000 × 1600 or 2080 × 1664 4K: 4000 × 3200 or 4080 × 3264 4:5 1K: 1024 × 1280 2K: 1600 × 2000 or 1664 × 2080 4K: 3200 × 4000 or 3264 × 4080
  1. Traditional Classic Aspect Ratios
4:3 1K: 1024 × 768 2K: 2048 × 1536 4K: 3840 × 2880 or 4096 × 3072 3:4 1K: 768 × 1024 2K: 1536 × 2048 4K: 2880 × 3840 or 3072 × 4096 3:2 1K: 1152 × 768 2K: 2160 × 1440 4K: 3840 × 2560 or 4080 × 2720 2:3 1K: 768 × 1152 2K: 1440 × 2160 4K: 2560 × 3840 or 2720 × 4080
  1. Widescreen and Ultrawide Aspect Ratios
16:9 1K: 1024 × 576 2K: 2048 × 1152 4K: 3840 × 2160 (Note: Standard 4K UHD perfectly satisfies 16:9 and both width and height are multiples of 16) 9:16 1K: 576 × 1024 2K: 1152 × 2048 4K: 2160 × 3840 21:9 (Equivalent to the simplest integer ratio 7:3) 1K: 1008 × 432 or 1120 × 480 2K: 2016 × 864 or 2128 × 912 4K: 3808 × 1632 or 4032 × 1728 9:21 (equivalent to the simplest integer ratio 3:7) 1K: 432 × 1008 or 480 × 1120 2K: 864 × 2016 or 912 × 2128 4K: 1632 × 3808 or 1728 × 4032