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:"png"
The format in which the generated images are returned. This parameter is only supported for the GPT image models. Must be one of png, jpeg, or webp.
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

Custom image dimensions must meet all of the following requirements: All recommended sizes below meet these requirements: