Image generation

For file inputs, upload through the Files API, then reference the returned file_id. The gateway converts the input; provider acceptance is determined upstream.

Reference assets with input_references: [{"type":"image","role":"reference","source":{"type":"file","file_id":"..."}}]. Type must match the image/audio/video file. The gateway replaces source with a COS signed URL, preserves role, then applies DSL. Existing required fields remain required. For Images and Speech, input_references is an InOneAPI extension.

The public contract follows OpenAI Images: POST /v1/images/generations. Native providers pass through; administrators map non-native JSON with DSL. InOneAPI requires an explicit public model ID instead of relying on OpenAI model defaults.

Minimal request

Replace YOUR_MODEL_ID with the exact model detail ID; do not add a provider prefix. Optional parameters and voices depend on the selected model. App attribution headers are commented out.

# -H "X-APP-NAME: Your App Name"
# -H "X-APP-URL: https://your-app.example.com"
curl "https://api.inoneapi.com/v1/images/generations" \
  -H "Authorization: Bearer $INONEAPI_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "model": "YOUR_MODEL_ID",
  "prompt": "A blue bird on a white background"
}'

Complete generation parameter reference

ParameterTypeComplete generation parameter reference
modelstringRequired public model ID, replaced by the selected upstream model ID.
promptstringRequired prompt describing subject, composition, style, text and constraints. Model-specific length limits apply.
nintegerOptional image count, commonly 1–10; some models allow only 1. Omitted defaults are upstream-defined.
sizestringOptional WIDTHxHEIGHT or auto. Common values: 1024x1024, 1536x1024, 1024x1536. Model-specific constraints apply; no gateway resizing.
qualitystringOptional auto/low/medium/high for GPT Image-style models, or standard/hd for some legacy models; not universally interchangeable.
stylestringOptional vivid/natural, only for models supporting this legacy style parameter.
response_formatstringOptional url/b64_json when supported. Native GPT Image always returns Base64 and does not accept response_format; omit it.
backgroundstringOptional auto/opaque/transparent. Transparency requires supporting models and png/webp, not jpeg.
output_formatstringOptional png/jpeg/webp, only when supported. Provider defaults apply when omitted.
output_compressionintegerOptional integer 0–100, only for jpeg/webp compression, not png.
moderationstringOptional auto/low when supported; this does not bypass provider safety controls.
userstringOptional end-user identifier. Avoid email addresses, phone numbers and sensitive identifiers.
streambooleanOptional boolean; non-streaming by default. Streaming passes through native providers only; request DSL cannot transform streaming requests.
partial_imagesintegerOptional integer 0–3 for streaming partial images. Not the total image count; the final image may arrive sooner.

Complete examples by model capability

No single all-parameter request is valid for every model. Examples separate GPT Image-style output from legacy style/URL parameters. Replace placeholder model IDs with enabled models. The streaming example covers partial_images.

curl https://api.inoneapi.com/v1/images/generations \
  -H "Authorization: Bearer $INONEAPI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "YOUR_MODEL_ID",
  "prompt": "A blue bird on a white background",
  "n": 1,
  "size": "1024x1024",
  "quality": "high",
  "background": "opaque",
  "output_format": "jpeg",
  "output_compression": 90,
  "moderation": "auto",
  "user": "user_123",
  "stream": false
}'
{"model":"YOUR_MODEL_ID","prompt":"A blue bird","n":1,"size":"1024x1024","quality":"hd","style":"vivid","response_format":"url","user":"user_123"}
curl -N https://api.inoneapi.com/v1/images/generations \
  -H "Authorization: Bearer $INONEAPI_API_KEY" -H 'Content-Type: application/json' \
  -d '{"model":"YOUR_MODEL_ID","prompt":"A blue bird","stream":true,"partial_images":2}'

Response fields and saving output

{
  "created":1788580800,
  "data":[{"b64_json":"REPLACE_WITH_IMAGE_BYTES"}],
  "background":"opaque",
  "output_format":"jpeg",
  "size":"1024x1024",
  "quality":"high",
  "usage":{"input_tokens":100,"output_tokens":1000,"total_tokens":1100,"input_tokens_details":{"text_tokens":60,"image_tokens":40}}
}
FieldResponse fields and saving output
createdInteger Unix seconds, unlike ISO timestamps in the video contract.
data[]Ordered result array. Usually corresponds to n; do not assume failed requests contain every result.
data[].b64_jsonBase64 image bytes without a data URL prefix. Decode using the returned output format.
data[].urlTemporary download URL only when supported. Download promptly; permanent hosting is not guaranteed.
data[].revised_promptOptional provider-revised prompt, not necessarily the original prompt.
background / output_format / size / qualityOptional actual background, format, dimensions and quality metadata.
usageOptional token usage; some providers omit it. Missing usage does not mean a free request.
usage.input_tokens / output_tokens / total_tokensOptional input, output and total tokens. input_tokens_details.text_tokens/image_tokens split input usage. Metering and pricing are configured separately.

Errors, streaming and boundaries

400 may indicate invalid parameters, media or DSL input; check credentials for 401/403; back off using Retry-After for 429. 502 may indicate failed normalization or a DSL response buffer overflow. Record X-Gateway-Trace-ID, not credentials or private images. Generation timeouts can have ambiguous outcomes: do not blindly retry. This is synchronous output or native SSE, not a video-style task API. Generic image task retrieval, asynchronous polling conversion and variations are not implemented. DSL does not transform SSE events. Large Base64 responses are bounded by GATEWAY_RESPONSE_BUFFER_BYTES (32 MiB by default); size it against concurrency and memory.

Administrator and AI mapping guide

Configure image_path. Use {"version":1} for native passthrough. Generation uses request/response. Native protocol is enabled by default; disable it to edit and test the DSL. Use mode=replace for strict provider schemas. See repository docs/image-protocol-dsl.md and docs/protocol-mapping-dsl.schema.json for complete fixtures, field mappings, enums and capability-gap checks. Protocol DSL does not set prices; metering reads raw upstream responses.

Try in the playground

The console Playground and the model detail “Try now” panel call this endpoint according to the model’s output modalities. They display and save data[].url and data[].b64_json results. Select the output type when a model supports both text and images. Catalog modality tabs match output capabilities only.

Image generation · Documentation · InOneAPI