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/generationsRequest
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 }'| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Image model ID (e.g. gpt-image-2, gemini-3.1-flash-image). |
prompt | string | Yes | Text description of the image to generate. |
size | string | No | Output resolution, e.g. 1024x1024. |
n | integer | No | Number 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:
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
| Symptom | Cause | Fix |
|---|---|---|
404 Not Found | Endpoint not yet mounted (see preview note) | Use chat/messages until the image surface ships. |
401 Unauthorized | Key missing or wrong | Pass a valid sk-ru-… key. |
402 Payment Required | Zero balance | Top up in the console → Billing. |
400 unknown model | Model ID not an image model | Use gpt-image-2 or gemini-3.1-flash-image. |