Call the GPT Image family through the Token Market unified image generation endpoint for text-to-image generation, with editing and output controls when supported by the current provider channel.
https://api.tokensmarket.ai/v1POST /images/generationsThe endpoint remains fixed. Use the parameter documentation on this page to replace the model ID and request data.
${base_url}/images/generationsAll media generation requests are authenticated through the Token Market unified gateway and use a JSON request body.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
Authorization | string | Yes | — | Append the current workspace API Key after Bearer. Options / constraints: Bearer <API_KEY>. |
Content-Type | string | Yes | application/json | Send the request body as JSON. |
model and prompt are the base fields. Other image controls take effect only when the current model and provider channel support them.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | The GPT Image model ID to call. Options / constraints: gpt-image-2. |
prompt | string | Yes | — | A prompt describing the desired scene, composition, subject, lighting, materials, and style. |
image | string | string[] | No | — | An image input for editing or reference. Options / constraints: Use only when the model details page indicates support for editing or reference images. |
size | string | No | — | The target image size. Options / constraints: See the current model details page for supported values. |
quality | string | No | — | The generation quality tier. Options / constraints: Use only when the current provider channel supports this field. |
background | string | No | — | The background treatment, such as transparent or opaque. Options / constraints: Use only when supported by the current provider channel and output format. |
output_format | string | No | — | The requested image file format. Options / constraints: Use only when the current provider channel supports this field. |
extra_body.provider | object | No | — | Restricts or ranks candidate provider channels. Options / constraints: Use fields such as only, ignore, order, and sort according to the unified routing rules. |
The image generation endpoint returns JSON. Available result fields depend on the model, provider channel, and requested output format.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
created | integer | No | — | The response creation time, usually as a Unix timestamp. |
data | array | No | — | The generated result list. Multi-image requests may return multiple results. |
data[].url | string | No | — | A temporary URL for the generated image. Options / constraints: Present only when the current model and provider channel return a URL. Copy the asset to your own storage promptly. |
data[].b64_json | string | No | — | The Base64-encoded image content. Options / constraints: Present only when the request and current provider channel support Base64 output. |
data[].revised_prompt | string | No | — | The prompt used or revised by the model. Options / constraints: Returned only by some models and provider channels. |
provider | string | No | — | Information about the provider channel that handled the request. |
request_id | string | No | — | A request identifier for log lookup and troubleshooting. Options / constraints: The field name may change with the current gateway response version. |
The model ID on this page comes from the confirmed Model Market snapshot. gpt-image-2 is the invocation identifier in the current Token Market catalog; do not infer that an identically named model exists in an upstream provider’s public catalog.
For live workloads, retain request_id, model, and provider, and validate the result URL or Base64 data before storing it. Use bounded retries for timeouts, rate limits, and upstream failures to avoid automatic duplicate charges.
The examples use placeholders. Replace them with a currently available model ID from the model details page, and keep your API Key in a server-side environment variable.
curl https://api.tokensmarket.ai/v1/images/generations \
-H "Authorization: Bearer $TOKEN_MARKET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A cinematic paper-cut city at sunrise",
"size": "1024x1024"
}'