Skip to main content

Image Generation

Generate images with AI models via the chat completions endpoint.

The OneRoute router now supports image‑generation models. Using the standard chat completions endpoint, the API can return generated images alongside normal text responses.

How It Works

Image‑generation models use the same /v1/chat/completions endpoint as text models, but the assistant message in the response includes an additional images array that contains the generated image(s).

Request Format

Send requests with the standard chat completions payload:

curl https://gw.1route.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ONEROUTE_API_KEY" \
-d '{
"model": "vertex/google/gemini-2.5-flash-image-preview",
"messages": [
{
"role": "user",
"content": "Generate an image of a sunset over mountains"
}
]
}'

Response Format

{
"model": "vertex/google/gemini-2.5-flash-image-preview",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I've generated an image of a sunset over mountains as requested.",
"images": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,your_base64_image"
}
}
]
}
}
]
}

Supported Models

  • Vertex AI Gemini: vertex/google/gemini-2.5-flash-image-preview

This model, provided through Google's Vertex AI platform, offers fast, high‑quality image generation.

Pricing for image‑generation models may differ from text models. Refer to the model details for exact pricing information.

Limitations

  • Generated images are returned as base64‑encoded data.
  • Image size and resolution depend on the specific model's capabilities.
  • Some models may enforce content filters or safety restrictions.
  • Response size limits apply to the combined text and image data.