Image Generations

Generates images from a text prompt using an OpenAI-compatible request. Model and prompt are required. JoyToken forwards supported image options to the selected provider and appends routing and billing details under metadata. This endpoint is non-streaming: do not send stream: true. JoyToken returns one application/json response after generation completes and never emits SSE events or [DONE].

身份验证

AuthorizationBearer

Use Authorization: Bearer $JOY_TOKEN_API_KEY.

请求头

X-Request-IDstring可选
Optional request identifier for deduplication, billing, logs, and debugging correlation.

请求

This endpoint expects an object.
modelenum必需

Must be auto. Concrete image model IDs are not accepted.

promptstring必需>=1 character
Text description of the image to generate.
ninteger可选>=1
Number of images to generate. Provider limits vary.
qualitystring可选

Provider-supported image quality, such as standard, hd, medium, or high.

response_formatenum可选

Output mode. Defaults to b64_json (base64 in data[].b64_json). Set url to receive a hosted image URL in data[].url instead; this only works when every eligible image model supports URL output, otherwise JoyToken falls back to b64_json. Omit unless you specifically need URL output.

sizestring可选

Provider-supported output dimensions, for example 1024x1024.

stylestring可选

Provider-supported image style.

userstring可选

Optional end-user identifier.

backgroundstring可选

Provider-supported background mode.

moderationstring可选

Provider-supported moderation setting.

output_compressioninteger可选0-100
Compression percentage for supported output formats.
output_formatstring可选

Provider-supported image format, such as png, jpeg, or webp.

响应

Successful non-streaming image generation result returned as one application/json document.

datalist of objects
createdlong可选
Unix timestamp for the generation result.
metadataobject可选

JoyToken routing and billing metadata appended by the gateway when available. In orchestration (multi-task planning) mode this object also carries per-task identifiers, and the response returns one metadata object per task.

错误

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
409
Conflict Error
429
Too Many Requests Error
500
Internal Server Error