Skip to content
TutujinAPI

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.

POSThttps://www.tutujin.com/v1/images/generations

Headers

HeaderRequiredDescription
AuthorizationYesBearer sk-..., an API key from the console
Content-TypeYesapplication/json

Request body

ParameterTypeRequiredDescription
modelstringYesModel name, e.g. gpt-image-2
promptstringYesWhat to draw. Spell out subject, setting, style, composition and lighting for steadier results
nintegerNoNumber of images, default 1. Some models only make one per request; send several requests in parallel for more
sizestringNoSize, e.g. 1024x1024, 1536x1024, 1024x1536. Allowed values vary by model
qualitystringNoQuality; GPT Image models accept low, medium, high, auto. Other models may ignore it
response_formatstringNourl for a link, b64_json for base64 data. Some models only support one of them
output_formatstringNoFile format such as png, jpeg, webp; some models only
backgroundstringNotransparent for a transparent background; some models only
aspect_ratiostringNoAspect ratio supported by some non-OpenAI models, e.g. 16:9 or 3:4

Request example

curl https://www.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"
  }'

Image generation is much slower than text chat, so give the client a generous timeout; the examples use 300 seconds.

Response example

JSON
{
  "created": 1794000000,
  "data": [
    {
      "url": "https://example.com/generated/mug.png",
      "revised_prompt": "..."
    }
  ]
}
FieldDescription
data[].urlA temporary link that expires; download it and keep the file in your own storage
data[].b64_jsonBase64 image data, when response_format is b64_json or the model only returns this format
data[].revised_promptSome models rewrite the prompt and return the version they actually used
usageToken-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 Logs 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

ModelVendorCheapest groupInput ¥/1MOutput ¥/1MPer request ¥
gpt-image-2OpenAIStandard——¥0.12
nano-banana-proGoogleStandard——¥0.4
fluxFluxStandard——¥0.02
flux-schnellFluxStandard——¥0.02
flux-devFluxStandard——¥0.06
gpt-image-2-allOpenAIStandard——¥0.08
dall-e-3OpenAIStandard——¥0.08
flux-proFluxStandard——¥0.1

Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 1:33 AM.

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.