Browse documentation

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/generations

Requests 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

ParameterTypeRequiredDefaultDescription
promptstringYes—Text description of the desired image (max 4,000 chars for DALL-E 3).
modelstringYes—Image generation model ID (e.g. dall-e-3, imagen-3).
nintegerNo1Number of images (1 for DALL-E 3; 1–4 for Imagen 3).
qualitystringNostandardImage quality: standard or hd.
response_formatstringNob64_jsonReturn format: url or b64_json.
sizestringNo1024x1024Output size (e.g. 1024x1024, 1024x1792, 1792x1024).
stylestringNovividStyle: vivid or natural (DALL-E 3).
userstringNo—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 StatusError CodeReason
400 Bad Requestinvalid_requestInvalid resolution, incompatible parameters, or prompt too long.
400 Bad Requestguardrail_blockedPrompt violated safety policies or injection guardrails.
401 Unauthorizedinvalid_api_keyVirtual key missing, expired, or invalid.
402 Payment Requiredinsufficient_creditsOrganization prepaid balance insufficient for image hold.
404 Not Foundmodel_not_foundImage model unrecognized or unauthorized.
429 Too Many Requestsrate_limit_exceededRPM or concurrent quota exceeded; check x-nr-limit-source.
POST
/v1/images/generations

Authorization

NRouterApiKey
AuthorizationBearer <token>

Your nRouter virtual key (sk-nrouter-…). Sent as Authorization: Bearer sk-nrouter-….

In: header

Header Parameters

x-nr-tags?string

Custom spend and attribution tags (comma-separated key=value pairs)

x-nr-mcp-server?string

Target MCP server ID when routing MCP tool calls or prompts through the gateway

x-nr-client-language?string

Caller SDK runtime language identification (e.g. typescript, python, rust, go)

x-nr-session-id?string

Caller session identifier allowed at edge for grouping related client turns

x-nr-trace?string

Inbound trace detail level override for request lifecycle spans

Value in

  • "off"
  • "stages"
  • "verbose"
x-nr-trace-stages?string

Inbound stage-level trace emission override

Value in

  • "off"
  • "stages"
  • "verbose"
x-nr-trace-id?string

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>"    }  ]}
Was this page helpful?