Lovely RouterDocs
Get a key
Models API

How the gateway works

Lovely Router passes each request to a model in the API format you sent it. This page covers the endpoints, model ids, auth headers, and the few things the gateway changes.

Lovely Router speaks the Anthropic, OpenAI and Gemini APIs on one host. It does not translate between them: a request in Anthropic format goes to a channel that accepts Anthropic format, and your request body reaches the channel as you wrote it, apart from two small changes. Called in its own vendor's API, a model gets your request exactly as the vendor documents it. Parameters such as thinking, cache_control, tools or generationConfig reach the model unchanged, so the vendor's own documentation applies.

Endpoints and base URLs#

Point your SDK at the base URL for its API. The SDK adds the path.

APIEndpointsSDK base URLGuide
Anthropic MessagesPOST /v1/messages, POST /v1/messages/count_tokenshttps://lovelyrouter.comAnthropic Messages
OpenAI Chat CompletionsPOST /v1/chat/completionshttps://lovelyrouter.com/v1OpenAI Chat Completions
OpenAI Responses (GPT models)POST /v1/responseshttps://lovelyrouter.com/v1Responses API
GeminiPOST /v1beta/models/{model}:generateContent, :streamGenerateContent, :countTokenshttps://lovelyrouter.comGemini
OpenAI Images (image models)POST /v1/images/generations, POST /v1/images/editshttps://lovelyrouter.com/v1Images
Videos (character swap)POST /v1/videoshttps://lovelyrouter.com/v1Video
Live videoPOST /v1/videos/livehttps://lovelyrouter.com/v1Live video
Music videosPOST /v1/videos/musichttps://lovelyrouter.com/v1Music videos
Model listGET /v1/models, GET /v1beta/modelsModels & pricing

Other model endpoints return 404. See what is not available. The data tools and browser agent APIs share the same host and keys.

Which API each model speaks#

Every model has a native API: the format its vendor designed it for. Use it when you can.

Model familyNative APIAlso accepted today
Claude (claude-*)Anthropic MessagesOpenAI Chat Completions, Gemini
GPT (gpt-*)OpenAI Chat Completions, OpenAI ResponsesAnthropic Messages, Gemini
Gemini (gemini-*)GeminiOpenAI Chat Completions, Anthropic Messages
GPT Image (gpt-image-*)OpenAI Imagesnone
Hosted models (dongfangshuo-*)OpenAI Chat CompletionsAnthropic Messages
Hosted image models (z-image-*)OpenAI Imagesnone

When you call a model in another format, the channel converts the request for the model, so some vendor features may not carry over. Vendor-specific parameters are defined for the vendor's own API. Anthropic cache_control and thinking, OpenAI reasoning_effort and Gemini thinkingConfig are only certain to work in the model's native format; in another format they may be ignored or rejected.

The formats a model accepts depend on the channels that serve it, so they can change. The marketplace shows them per model. If no channel accepts your format, the request fails with 404 and a message like Model 'gpt-6.1-sol' is not served in gemini format in any group.

Model ids#

Use the ids from GET /v1/models, such as claude-sonnet-5.5, gpt-6.1-sol or gemini-3.1-pro. The gateway also accepts the spellings other tools use and resolves them to the same model:

You sendResolves to
claude-sonnet-5-5claude-sonnet-5.5
anthropic/claude-sonnet-5.5claude-sonnet-5.5
claude-haiku-4-5-20251001claude-haiku-4.5
gemini-3.1-pro-previewgemini-3.1-pro
models/gemini-3-flashgemini-3-flash

The rules: case is ignored, a leading vendor/ or models/ prefix is dropped, . and - are interchangeable, and a trailing date (-20251001), -preview or -latest is dropped. Logs, key allow-lists and billing always use the canonical id.

An id that matches no model returns 404 with Model '<id>' is not available. See GET /v1/models.

What the gateway changes#

The request body is forwarded as you sent it, with two exceptions:

  1. The model id. It is replaced with the id the serving channel expects. The model field in the response may therefore use the vendor's spelling, for example claude-sonnet-5-5.
  2. Usage on OpenAI streams. Streaming Chat Completions requests get stream_options.include_usage: true, so the gateway can bill the call. Your stream ends with one extra chunk that has an empty choices array and a usage object. Guard for choices being empty when you read chunks.

Request headers are not forwarded, except anthropic-version, anthropic-beta and openai-beta. When anthropic-version is missing, 2023-06-01 is sent. On Gemini endpoints, query parameters such as alt=sse are forwarded; key is removed.

Responses come back byte for byte. The gateway keeps the content-type and cache-control headers and adds its own (see response headers). Vendor request ids and rate-limit headers are not passed through.

When a model rejects a request as invalid (400, 404, 413, 422), you get the same status and the reason, in your API's error format. Other failures are retried on another channel first. See Rate limits & failover and Errors.

Authentication#

Every endpoint accepts your key in any of these places, so each SDK works with its default auth:

WhereUsed by
Authorization: Bearer lr-...OpenAI SDK, Claude Code with ANTHROPIC_AUTH_TOKEN, most HTTP clients
x-api-key: lr-...Anthropic SDK
x-goog-api-key: lr-...Google Gen AI SDK, Gemini CLI
?key=lr-... query parameterGemini REST examples

GET /v1/models and GET /v1beta/models need no key. See Authentication for key handling.

Response headers#

HeaderValue
x-lovely-request-idId of this call, for example req_6f1c.... Matches the entry in Logs. Include it when you contact support.
x-lovely-groupThe channel group that served the call, for example claude-value.
x-lovely-channelThe group's channel label, URL-encoded, for example Pooled%20capacity.
x-lovely-queued-msOnly when the call waited for capacity: milliseconds spent waiting.

Browsers can read the first three: they are listed in access-control-expose-headers.

Lifecycle of a request#

  1. Authenticate. The key must be active and not expired, or you get 401.
  2. Resolve the model. The id is resolved as described above and checked against the key's model allow-list (403 if not allowed).
  3. Check the balance. A balance at or below zero, or a key past its spend limit, returns 402.
  4. Apply key limits. A key's requests-per-minute and concurrency limits are enforced (429). See Rate limits & failover.
  5. Pick a channel. A conversation already in progress goes back to the channel that holds its prompt cache. New conversations go to the best available channel in the channel group. See Prompt caching.
  6. Call the model. If a channel fails before producing output, the request moves to another channel, up to three attempts. Streams are held until the first token so this stays invisible. See Streaming.
  7. Meter and log. Token counts from the response set the charge, which is deducted from your balance within seconds. See Models & pricing.

What is not available#

Only the endpoints above exist. These return 404:

  • Stored OpenAI responses (/v1/responses/{id}), legacy Completions, embeddings, image variations, audio, files and batches.
  • Anthropic Message Batches, Files and Models-by-id endpoints.
  • Gemini cachedContents (explicit context caching), file uploads, embedContent and the Live API.

The OpenAI Responses API is served for GPT models only. Use with your tools has settings for common clients.