Skip to content

API reference

The API is served from https://gw.lunaroute.com. All endpoints share the same authentication; error envelopes follow the request dialect (see Errors).

Endpoint Shape
POST /v1/chat/completions OpenAI Chat Completions
POST /v1/completions Legacy OpenAI completions
POST /v1/messages Anthropic Messages
POST /v1/messages/count_tokens Anthropic token counting
POST /v1/responses (and /responses) Responses API
POST /v1/embeddings Embeddings
POST /v1/rerank Rerank
POST /v1/images/generations Image generation
POST /v1/images/edits Image editing
POST /v1/images/uploads Image upload
GET /v1/models Model catalog

Embeddings and rerank run in their own lane pool, so they never consume interactive capacity. Image generation uses interactive lanes by default; a background-marked request uses the background pool when the organization is entitled to background lanes.

Most endpoints return one envelope:

{ "error": { "code": "INVALID_API_KEY", "message": "Invalid or revoked API key" } }

Anthropic-dialect requests (/v1/messages) are not uniform: most errors (including auth failures) return the envelope above, while some Anthropic-shaped errors wrap it as { "type": "error", "error": { … } }. Auth codes are listed on Authentication, and Errors & rate limits covers 429, Retry-After, and retryable 503s.

Some features are operator-gated. When a feature is switched off, its endpoint answers 503 with a <feature>_disabled code rather than disappearing, so the route table is stable. Treat these as “temporarily unavailable”, not “not found”.