API Reference

Create Image

Creates an image given a prompt. Compatible with the OpenAI Images API. Automatically routes to the best available provider. Image model availability differs by deployment: the self-hosted gateway serves this endpoint with any image-output model you configure, and `GET /v1/models` lists what is currently available on the instance you are calling. With `stream=true`, the response is a Server-Sent Events stream of partial and completed image events for `gpt-image-*` models; any other model rejects the streaming ask with a 400.

Examples on this page use the YoloRouter Cloud endpoint

Self-hosting? Replace https://api.yolorouter.com with your own instance, which defaults to http://localhost:8080.

Self-hosting guide →
POST
/v1/images/generations

Authorization

ApiKeyAuth
AuthorizationBearer <token>

Your Yolo Router API key. Format: Authorization: Bearer sk-...

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://api.yolorouter.com/v1/images/generations" \  -H "Content-Type: application/json" \  -d '{    "model": "<image-model-id>",    "prompt": "A cute cat sitting on a sunny beach",    "n": 1,    "size": "1024x1024"  }'
{
  "created": 0,
  "data": [
    {
      "url": "string",
      "b64_json": "string",
      "revised_prompt": "string"
    }
  ]
}
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_api_key",
    "message": "Invalid API key"
  }
}
{
  "error": {
    "type": "insufficient_quota",
    "code": "insufficient_quota",
    "message": "Quota exceeded"
  }
}
{
  "error": {
    "type": "string",
    "code": "string",
    "message": "string"
  }
}