Skip to content

First request

All API paths are served from https://gw.lunaroute.com. The same API key works across dialects.

Terminal window
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.

Terminal window
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.

Terminal window
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."
}'

By default a request is realtime. For work that can wait — batch evals, indexing — use the -background form of the model id:

Terminal window
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.

Terminal window
curl https://gw.lunaroute.com/v1/models \
-H "LUNAROUTE-API-KEY: $LUNAROUTE_API_KEY"

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.