Image generation
Create images from a text prompt with an OpenAI-compatible endpoint.
/v1/images/generations
Generates one or more images from a text prompt. The endpoint follows the OpenAI Images API, so the official OpenAI SDKs work unchanged — point them at https://rutoken.ai/v1. Models such as gpt-image-1, dall-e-3, dall-e-2 and Google Imagen (imagen-*) can be called through it; the exact list depends on what is enabled in the Model Square.
Authentication
Send your key in the Authorization: Bearer sk-xxxx header.
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Model ID, e.g. gpt-image-1, dall-e-3. |
prompt |
string | Yes | Text description of the image. Max length: 32000 characters for gpt-image-1, 4000 for dall-e-3, 1000 for dall-e-2. |
n |
integer | No | Number of images, 1–10. dall-e-3 supports only 1. |
size |
string | No | gpt-image-1: 1024x1024, 1536x1024, 1024x1536 or auto. dall-e-3: 1024x1024, 1792x1024, 1024x1792. dall-e-2: 256x256, 512x512, 1024x1024. Use the letter x, not ×. |
quality |
string | No | dall-e-3: standard (default) or hd. gpt-image-1: low, medium, high or auto. |
style |
string | No | dall-e-3 only: vivid or natural. |
response_format |
string | No | url or b64_json. gpt-image-1 always returns b64_json. |
background |
string | No | gpt-image-1 only: transparent, opaque or auto. A transparent background needs output_format png or webp. |
output_format |
string | No | gpt-image-1 only: png, jpeg or webp. |
output_compression |
integer | No | gpt-image-1 only, 0–100, for jpeg / webp. |
moderation |
string | No | gpt-image-1 only: low or auto. |
stream |
boolean | No | Stream partial images (gpt-image-1, when the upstream supports it). |
partial_images |
integer | No | Number of partial images to stream, 0–3. |
user |
string | No | End-user identifier for abuse monitoring. |
When the request is routed to a Google Imagen model, size is converted to an aspect ratio (1792x1024 → 16:9, 1024x1536 → 2:3, …). You can also pass a ratio such as 16:9 directly.
Request example
curl https://rutoken.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "gpt-image-1",
"prompt": "A watercolor fox reading a book under a tree",
"size": "1024x1024",
"quality": "medium"
}'
import base64
from openai import OpenAI
client = OpenAI(base_url="https://rutoken.ai/v1", api_key="sk-xxxx")
resp = client.images.generate(
model="gpt-image-1",
prompt="A watercolor fox reading a book under a tree",
size="1024x1024",
quality="medium",
)
# gpt-image-1 returns base64 data
with open("fox.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://rutoken.ai/v1", apiKey: "sk-xxxx" });
const resp = await client.images.generate({
model: "gpt-image-1",
prompt: "A watercolor fox reading a book under a tree",
size: "1024x1024",
quality: "medium",
});
// gpt-image-1 returns base64 data
fs.writeFileSync("fox.png", Buffer.from(resp.data[0].b64_json, "base64"));
A dall-e-3 request that returns a URL:
curl https://rutoken.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "A futuristic city skyline at sunset, cinematic lighting",
"size": "1792x1024",
"quality": "hd",
"style": "vivid",
"response_format": "url"
}'
Response
{
"created": 1760000000,
"data": [
{
"url": "https://example.com/generated/image.png",
"revised_prompt": "A futuristic city skyline at sunset with cinematic lighting..."
}
],
"usage": {
"total_tokens": 4240,
"input_tokens": 50,
"output_tokens": 4190,
"input_tokens_details": { "text_tokens": 50, "image_tokens": 0 }
}
}
| Field | Type | Description |
|---|---|---|
created |
integer | Unix timestamp. |
data[].url |
string | Image URL (when response_format is url). Upstream URLs usually expire after a short time — download them promptly. |
data[].b64_json |
string | Base64-encoded image (when response_format is b64_json, and always for gpt-image-1). |
data[].revised_prompt |
string | Prompt actually used by dall-e-3. |
usage |
object | Token usage, returned by token-billed models such as gpt-image-1. |
Gemini image models
Gemini's native image models (for example gemini-2.5-flash-image) are not served by this endpoint — only Imagen models are. Call them through:
- Chat Completions —
POST /v1/chat/completionswith the image model asmodel; - the Gemini native format —
POST /v1beta/models/{model}:generateContentwithx-goog-api-key: sk-xxxx.
See also: Image editing, Errors.