Messages (Anthropic)
POST /v1/messages speaks the Anthropic Messages shape, so an Anthropic client
can route through LunaRoute by changing its base URL and key.
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": "hello"}] }'POST /v1/messages/count_tokens counts input tokens for the same shape.
Auth note
Section titled “Auth note”Use the LUNAROUTE-API-KEY header. Authorization: Bearer lr_… and
x-api-key: lr_… are also accepted when the value is lr_-prefixed — which
means an Anthropic client configured with x-api-key works unchanged.
Claude Code passes the header through ANTHROPIC_CUSTOM_HEADERS; the CLI’s
lunaroute setup claude-code wires this for you, along with the MCP server.
LunaRoute-specific behavior
Section titled “LunaRoute-specific behavior”Background model variants and project attribution work exactly as in
Chat completions. Both /v1/messages and
/v1/responses route to the same models as /v1/chat/completions.