Browse docs ▾
API reference

Image generation

Generate images through the same /v1/chat/completions endpoint - add modalities: ["image", "text"] and images come back inside the assistant message. No separate images API, so routing, failover, streaming, and metering all apply unchanged.

Request

Target an image-capable model (bold/image auto-routes across providers) and declare the output modalities. The conversation is the interface: follow-up messages edit or iterate on the image with full context.

javascript
const res = await client.chat.completions.create({
  model: "bold/image",
  modalities: ["image", "text"],
  messages: [{ role: "user", content: "A lighthouse at dawn, watercolor" }],
  image_config: { aspect_ratio: "16:9" },   // optional
});

const image = res.choices[0].message.images?.[0];
// image.image_url.url → "data:image/png;base64,...."

image_config is optional: aspect_ratio (e.g. "1:1", "16:9", "9:16") is mapped to each provider's native control; size (e.g. "1024x1024") passes through where supported.

Response

Generated images arrive as base64 data URLs in the assistant message's images array - the gateway hosts nothing and stores nothing.

json
{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "Here is your lighthouse at dawn.",
      "images": [{
        "type": "image_url",
        "image_url": { "url": "data:image/png;base64,iVBORw0KGgo..." }
      }]
    },
    "finish_reason": "stop"
  }]
}

With stream: true, image fragments ride in delta.images on a chunk, alongside the usual delta.content text tokens.

Model discovery

Filter the catalog by output modality, OpenRouter-style:

bash
curl "https://boldrouter.com/v1/models?output_modalities=image" \
  -H "Authorization: Bearer $BOLD_API_KEY"
  • bold/image - auto-routes across providers' image models with health-based failover.
  • google/gemini-2.5-flash-image - conversational generation and editing, text alongside images.
  • openai/gpt-image-1 - OpenAI's image model; your last user message is the prompt.

Pricing

Images bill per generated image (the image_per_unit rate in /v1/models), on top of the request's token cost. Usage events, spend caps, balance reservations, and the dashboard ledger account for image cost exactly like token cost.

Routing strategies, provider preferences, fault injection, and the x-bold-* response headers all work on image requests - force a provider outage and watch an image request fail over, exactly like chat.