API reference
Image generation
Parameters, request and response examples for POST /v1/images/generations. Same format as the OpenAI image generation API, so one code path calls GPT Image, Gemini, Flux, Doubao Seedream and other image models. Requests are relayed as-is.
POST /v1/images/generations creates images from a text description, in the same format as the OpenAI Images API. GPT Image, Gemini (Nano Banana), Flux, Doubao Seedream and the other image models in the catalog can all be called through it. Requests are relayed to the model service in their original format; supported sizes, quality levels and other values differ by model and follow that model's official documentation. Many image models are billed per request — see the price table below or the model's page.
https://open.tutujin.com/v1/images/generationsHeaders
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer sk-..., an API key from the console |
Content-Type | Yes | application/json |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name, e.g. gpt-image-2 |
prompt | string | Yes | What to draw. Spell out subject, setting, style, composition and lighting for steadier results |
n | integer | No | Number of images, default 1. Some models only make one per request; send several requests in parallel for more |
size | string | No | Size, e.g. 1024x1024, 1536x1024, 1024x1536. Allowed values vary by model |
quality | string | No | Quality; GPT Image models accept low, medium, high, auto. Other models may ignore it |
response_format | string | No | url for a link, b64_json for base64 data. Some models only support one of them |
output_format | string | No | File format such as png, jpeg, webp; some models only |
background | string | No | transparent for a transparent background; some models only |
aspect_ratio | string | No | Aspect ratio supported by some non-OpenAI models, e.g. 16:9 or 3:4 |
Request example
curl https://open.tutujin.com/v1/images/generations \
-H "Authorization: Bearer $TUTUJIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A ceramic insulated mug on a white background, soft studio light, product photo, slightly above eye level",
"size": "1024x1024"
}'import base64
import os
from openai import OpenAI
client = OpenAI(base_url="https://open.tutujin.com/v1", api_key=os.environ["TUTUJIN_API_KEY"], timeout=300)
resp = client.images.generate(
model="gpt-image-2",
prompt="A ceramic insulated mug on a white background, soft studio light, product photo, slightly above eye level",
size="1024x1024",
)
img = resp.data[0]
if img.b64_json:
with open("mug.png", "wb") as f:
f.write(base64.b64decode(img.b64_json))
else:
print(img.url) # temporary link: download and store it right awayimport fs from 'node:fs'
import OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://open.tutujin.com/v1', apiKey: process.env.TUTUJIN_API_KEY, timeout: 300_000 })
const resp = await client.images.generate({
model: 'gpt-image-2',
prompt: 'A ceramic insulated mug on a white background, soft studio light, product photo, slightly above eye level',
size: '1024x1024',
})
const img = resp.data[0]
if (img.b64_json) fs.writeFileSync('mug.png', Buffer.from(img.b64_json, 'base64'))
else console.log(img.url) // temporary link: download and store it right awayImage generation is much slower than text chat, so give the client a generous timeout; the examples use 300 seconds.
Response example
{
"created": 1794000000,
"data": [
{
"url": "https://example.com/generated/mug.png",
"revised_prompt": "..."
}
]
}| Field | Description |
|---|---|
data[].url | A temporary link that expires; download it and keep the file in your own storage |
data[].b64_json | Base64 image data, when response_format is b64_json or the model only returns this format |
data[].revised_prompt | Some models rewrite the prompt and return the version they actually used |
usage | Token-billed image models return input and output tokens; per-request models may omit it |
Handle both url and b64_json when parsing results.
Notes
- This endpoint is relayed as-is and has not been verified separately on this site. Each image model accepts different values, so confirm size and response format with a request or two first.
- Returned links are temporary. Do not store them for long-term use; download the image and keep it in your own object storage.
- Billing depends on the model: some charge per request, some by tokens. The Usage page in the console is the record.
- A prompt that trips the content safety policy returns an error. Change the prompt; retrying it unchanged will not work.
- For several images from a model that ignores
n, send parallel requests and keep concurrency under control.
Models that support this endpoint
| Model | Vendor | Cheapest group | Input ¥/1M | Output ¥/1M | Per request ¥ |
|---|---|---|---|---|---|
| gpt-image-2 | OpenAI | Standard | — | — | ¥0.12 |
| nano-banana-pro | Standard | — | — | ¥0.4 | |
| flux-schnell | Flux | Standard | — | — | ¥0.02 |
| flux | Flux | Standard | — | — | ¥0.02 |
| flux-dev | Flux | Standard | — | — | ¥0.06 |
| gpt-image-2-all | OpenAI | Standard | — | — | ¥0.08 |
| dall-e-3 | OpenAI | Standard | — | — | ¥0.08 |
| flux-pro | Flux | Standard | — | — | ¥0.1 |
Prices in CNY, cheapest group for each model; updated Nov 12, 2026, 8:17 PM.
54 models support this endpoint; the table shows some of them. See them all in the model hub
Still stuck? Add our WeChat support JsnonoChat and send the request id from the error message, and we will look into it.