Use the native Seedream image API for generation and supported editing or composition workflows.
https://api.tokensmarket.aiPOST /api/v3/images/generationsThe endpoint remains fixed. Use the parameter documentation on this page to replace the model ID and request data.
${base_url}/api/v3/images/generationsAll media generation requests are authenticated through the Token Market gateway. JSON requests use application/json; multipart requests are automatically generated by the client Content-Type boundary.
| 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. |
Send requests with the unified fields. Seedream-specific fields take effect only when the selected version and current provider channel support them.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | The exact Seedream model ID to call. Options / constraints: seedream-5-0-lite; seedream-4-5; seedream-4-0 |
prompt | string | Yes | — | Describe the target image and, for editing tasks, what to preserve and what to change. |
image | string | string[] | No | — | The input image for an editing or reference task. Options / constraints: Use only when the selected version supports image input. See the model details page for format and quantity limits. |
size | string | No | — | The target image size or resolution. Options / constraints: Custom dimensions and available ranges depend on the selected version. |
sequential_image_generation | string | No | — | Controls whether to generate a sequence of related images. Options / constraints: Available only for versions and provider channels that support image sequences. |
sequential_image_generation_options.max_images | integer | No | — | The maximum number of images a sequence task may return. Options / constraints: Use only when sequential_image_generation is active; the range is 1–15 |
output_format | string | No | — | The requested image file format. Options / constraints: Supported values depend on the selected version and current provider channel. |
watermark | boolean | No | — | Whether to add a watermark when supported by the current model. |
optimize_prompt_options | object | No | — | Native prompt optimization options when supported by the model. |
optimize_prompt_options.mode | string | No | — | Prompt optimization mode. |
response_format | string | No | — | Non-streaming result format. |
stream | boolean | No | — | Set to true to request SSE. |
tools | array | No | — | Native tool configuration when supported by the model. |
tools[].type | string | No | — | Type of tool configuration. |
extra_body.provider | object | No | — | Limit or sort candidate provider channels. Options / constraints: Use fields such as only, ignore, order, and sort according to the unified routing rules. |
When stream=false, the endpoint returns JSON; when stream=true, it returns SSE. Available fields depend on the model, channel, and requested output format.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | No | — | ID of the model that handled the request. |
data | array | No | — | List of generated results. |
data[].url | string | No | — | A temporary URL for the generated image. Options / constraints: Result URLs may expire. |
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[].output_format | string | No | — | File format of the result image. |
data[].size | string | No | — | Dimensions of the result image. |
data[].error | object | No | — | Error information when an individual result fails to generate. |
error | object | No | — | Top-level error information when the request fails. |
tools | array | No | — | Tool results used for this request. |
usage | object | No | — | Usage information for this request. |
usage.generated_images | integer | No | — | Number of generated images. |
usage.input_images | integer | No | — | Number of input images. |
usage.output_tokens | integer | No | — | Number of output tokens. |
usage.total_tokens | integer | No | — | Total number of tokens. |
usage.tool_usage.web_search | object | No | — | Usage information for the web search tool. |
provider | string | No | — | Information about the service provider channel that actually carries the request. Options / constraints: This field may appear only in non-streaming JSON responses. |
The following fields are HTTP response headers, not JSON or SSE response body fields.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
X-Client-Request-Id | string | No | — | Echoed when supplied by the caller; not generated automatically when omitted. |
X-Upstream-Request-Id | string | No | — | Usually used for gateway request tracing; it is not the provider's original request ID. |
seedream-5-0-lite, seedream-4-5, and seedream-4-0 use the same unified endpoint, but their capabilities, pricing, latency, and limits may differ. Keep regression examples and recheck the model details when switching versions.
Submit image or image-sequence fields only when the model details page explicitly shows that capability. Unrecognized extension fields may be rejected or ignored; applications should not assume identical behavior across versions.
When stream=false, the endpoint returns JSON. When stream=true, it returns SSE, ends with the image_generation.completed event, and does not append data: [DONE]. Handle errors in the stream; the completion event is not guaranteed if the connection is interrupted.
Result URLs may expire. After a successful response, download the result promptly, verify its content type, and save it to your own object storage. Also save the associated response headers, model, and sanitized input metadata. The provider field may appear only in non-streaming JSON responses.
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/api/v3/images/generations \
-H "Authorization: Bearer $TOKEN_MARKET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-5-0-lite",
"prompt": "A cinematic paper-cut city at sunrise",
"sequential_image_generation": "auto",
"sequential_image_generation_options": {"max_images": 4},
"extra_body": {"provider": {"sort": ["latency"]}}
}'