Skip to content

Image generation

ru-llm exposes image models (gpt-image-2, gemini-3.1-flash-image) through an OpenAI-compatible image-generation endpoint.

Endpoint

POST https://api.ru-llm.relay2.xyz/v1/images/generations

Request

Terminal window
curl https://api.ru-llm.relay2.xyz/v1/images/generations \
-H "Authorization: Bearer sk-ru-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A red panda coding at a laptop, soft studio lighting",
"size": "1024x1024",
"n": 1
}'
FieldTypeRequiredDescription
modelstringYesImage model ID (e.g. gpt-image-2, gemini-3.1-flash-image).
promptstringYesText description of the image to generate.
sizestringNoOutput resolution, e.g. 1024x1024.
nintegerNoNumber of images to generate. Default: 1.

Response

The response follows the OpenAI images format, returning base64-encoded image data:

{
"created": 1710000000,
"data": [
{"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."}
]
}

Decode the first image to a PNG file:

Terminal window
curl ... | python3 -c "import sys,json,base64; \
open('out.png','wb').write(base64.b64decode(json.load(sys.stdin)['data'][0]['b64_json']))"

Billing

Billing depends on the model. gpt-image-2 is billed per token (input/output), the same way chat models are. gemini-3.1-flash-image is billed per generated image (the per_image rate), charged once the image is produced. See the Models & Pricing page for current rates.

Troubleshooting

SymptomCauseFix
404 Not FoundEndpoint not yet mounted (see preview note)Use chat/messages until the image surface ships.
401 UnauthorizedKey missing or wrongPass a valid sk-ru-… key.
402 Payment RequiredZero balanceTop up in the console → Billing.
400 unknown modelModel ID not an image modelUse gpt-image-2 or gemini-3.1-flash-image.