First request
All API paths are served from https://gw.lunaroute.com. The same API key works
across dialects.
OpenAI Chat Completions
Section titled “OpenAI Chat Completions”curl https://gw.lunaroute.com/v1/chat/completions \ -H "LUNAROUTE-API-KEY: $LUNAROUTE_API_KEY" \ -H "content-type: application/json" \ -d '{ "model": "glm-5.3", "messages": [{"role": "user", "content": "Explain lanes in one paragraph."}], "stream": true }'Set "stream": true for server-sent events. Non-streaming responses follow the
OpenAI chat-completions shape.
Anthropic Messages
Section titled “Anthropic Messages”curl https://gw.lunaroute.com/v1/messages \ -H "LUNAROUTE-API-KEY: $LUNAROUTE_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{ "model": "glm-5.3", "max_tokens": 256, "messages": [{"role": "user", "content": "Say hello in one sentence."}] }'POST /v1/messages/count_tokens counts input tokens for the same shape.
Responses API
Section titled “Responses API”curl https://gw.lunaroute.com/v1/responses \ -H "LUNAROUTE-API-KEY: $LUNAROUTE_API_KEY" \ -H "content-type: application/json" \ -d '{ "model": "glm-5.3", "input": "Say hello in one sentence." }'Background work
Section titled “Background work”By default a request is realtime. For work that can wait — batch evals,
indexing — use the -background form of the model id:
curl https://gw.lunaroute.com/v1/chat/completions \ -H "LUNAROUTE-API-KEY: $LUNAROUTE_API_KEY" \ -H "content-type: application/json" \ -d '{"model": "glm-5.3-background", "messages": [{"role": "user", "content": "hello"}]}'Background requests are scheduled at a lower fair-share priority. See Lanes & scheduling for details.
Listing models
Section titled “Listing models”curl https://gw.lunaroute.com/v1/models \ -H "LUNAROUTE-API-KEY: $LUNAROUTE_API_KEY"Errors
Section titled “Errors”Most endpoints use this envelope:
{ "error": { "code": "INVALID_API_KEY", "message": "Invalid or revoked API key" } }Some Anthropic-shaped errors wrap it differently — see Errors & rate limits.
The Authentication page lists the auth
codes; Lanes covers CONCURRENT_REQUEST_LIMIT_EXCEEDED.