Image Generations
Generate photorealistic images and custom graphics from descriptive text prompts across multi-cloud vision models with transparent per-image list pricing.
The /v1/images/generations endpoint provides programmatic image generation across vision models including DALL-E 3 and Imagen 3. It features automated multi-cloud failover, pre-generation prompt safety inspection, transparent per-image list pricing, and centralized billing.
POST https://api.nrouter.ai/v1/images/generationsRequests run preflight as Chat Completions: key validation, rate limits, and content inspection (x-nr-guardrails: blocked returns HTTP 400 with zero spend). Fixed per-image credit reservations settle upon synthesis.
Request Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | — | Text description of the desired image (max 4,000 chars for DALL-E 3). |
model | string | Yes | — | Image generation model ID (e.g. dall-e-3, imagen-3). |
n | integer | No | 1 | Number of images (1 for DALL-E 3; 1–4 for Imagen 3). |
quality | string | No | standard | Image quality: standard or hd. |
response_format | string | No | b64_json | Return format: url or b64_json. |
size | string | No | 1024x1024 | Output size (e.g. 1024x1024, 1024x1792, 1792x1024). |
style | string | No | vivid | Style: vivid or natural (DALL-E 3). |
user | string | No | — | Unique end-user identifier for abuse monitoring. |
Response
{
"created": 1700000000,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6...",
"revised_prompt": "A modern minimalist server room illuminated in soft neon indigo."
}
]
}Examples
curl -X POST https://api.nrouter.ai/v1/images/generations \
-H "Authorization: Bearer $NROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"dall-e-3","prompt":"Futuristic server room.","size":"1024x1024"}'Headers & Errors
Required request headers: Authorization: Bearer sk-nrouter-... and Content-Type: application/json. Response telemetry includes x-nr-request-id, x-nr-latency-ms, x-nr-request-cost, x-nr-model. See Chat Completions.
| HTTP Status | Error Code | Reason |
|---|---|---|
| 400 Bad Request | invalid_request | Invalid resolution, incompatible parameters, or prompt too long. |
| 400 Bad Request | guardrail_blocked | Prompt violated safety policies or injection guardrails. |
| 401 Unauthorized | invalid_api_key | Virtual key missing, expired, or invalid. |
| 402 Payment Required | insufficient_credits | Organization prepaid balance insufficient for image hold. |
| 404 Not Found | model_not_found | Image model unrecognized or unauthorized. |
| 429 Too Many Requests | rate_limit_exceeded | RPM or concurrent quota exceeded; check x-nr-limit-source. |
Authorization
NRouterApiKey Your nRouter virtual key (sk-nrouter-…). Sent as Authorization: Bearer sk-nrouter-….
In: header
Header Parameters
Target MCP server ID when routing MCP tool calls or prompts through the gateway
Caller SDK runtime language identification (e.g. typescript, python, rust, go)
Caller session identifier allowed at edge for grouping related client turns
Inbound trace detail level override for request lifecycle spans
Value in
- "off"
- "stages"
- "verbose"
Inbound stage-level trace emission override
Value in
- "off"
- "stages"
- "verbose"
Accepted so a client sending it is not refused; the value is not recorded and not propagated. Every response carries the gateway's own trace ID in this header, never the one sent.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v1/images/generations" \ -H "Content-Type: application/json" \ -d '{ "model": "dall-e-3", "prompt": "A sleek minimalist server room in deep twilight blue.", "size": "1024x1024" }'{ "created": 1700000000, "data": [ { "b64_json": "<base64-png>" } ]}