Skip to content

Images API ​

OpenAI-compatible image generation, so an OpenAI client pointed at Console works unchanged.

Generate ​

POST /api/client/v1/images/generations

Request ​

json
{
  "model": "gpt-image-2",
  "prompt": "A watercolor fox reading a book under a streetlamp",
  "n": 1,
  "size": "1024x1024",
  "quality": "high",
  "response_format": "b64_json"
}

Parameters ​

FieldTypeRequiredDescription
modelstringYesModel key from the Model Hub. Must be a model in the image category.
promptstringYesText description of the desired image.
nnumberNoNumber of images to generate. Must be positive.
sizestringNoe.g. 1024x1024. Forwarded as-is to the upstream model.
qualitystringNoe.g. standard, hd, high — depends on the upstream model.
stylestringNoForwarded as-is (DALL·E-style models).
backgroundstringNoe.g. transparent, opaque (gpt-image-* models).
output_formatstringNoe.g. png, jpeg, webp (gpt-image-* models).
response_formatstringNourl or b64_json. gpt-image-* models always return base64 and reject this field, so it is only forwarded when set.
userstringNoOpaque end-user identifier, forwarded upstream.

Response ​

json
{
  "created": 1725480000,
  "data": [
    { "b64_json": "iVBORw0KG...", "revised_prompt": "A watercolor-style illustration of a fox..." }
  ],
  "request_id": "req_..."
}

Each data[] entry carries whichever of b64_json / url the upstream returned, plus revised_prompt when the model rewrote the prompt.

Billing and quota ​

Image models bill per image, not per token — the model's pricing entry in the Model Hub carries a per-image rate. The pre-flight quota check counts the request itself (rate limit) and settles the budget from usage.images (or data.length when the upstream didn't report a count) after the call completes.

Errors ​

StatusDescription
400Missing model or prompt, or n is not a positive number
401Invalid API token
404Model key not found, or not an image-category model
429Rate limit or budget exceeded
500Upstream or internal error

Example ​

bash
curl -X POST https://gateway.example.com/api/client/v1/images/generations \
  -H "Authorization: Bearer cpeer_your_token" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A watercolor fox reading a book under a streetlamp",
    "response_format": "b64_json"
  }'

Where to go next ​

  • Model Hub — deploy an image-category model and try it from the built-in Playground.
  • Chat Completions — the text counterpart of this endpoint.

Studio · Pulse · Console · Agent SDK and more — the Cognipeer documentation hub