Authentication
Authenticate requests to the MisarCoder gateway with a bearer API key.
MisarCoder authenticates every request with a bearer API key.
Bearer token
Send your key in the Authorization header:
Authorization: Bearer YOUR_MISARCODER_API_KEYAnthropic-style header
The /v1/messages endpoint additionally accepts the Anthropic x-api-key: YOUR_MISARCODER_API_KEY header, so the stock Anthropic SDK works unchanged. If both Authorization and x-api-key are present, Authorization takes precedence.
How validation works
- When the gateway is configured with an API key, requests without a valid bearer token are rejected with
401 Unauthorized. - Token comparison is constant-time.
- If the gateway is deployed without a configured key (local/dev mode), authentication is skipped and all requests are accepted. Do not run a public deployment without a key.
claude-* passthrough
When you call /v1/messages with a claude-* model, the gateway forwards your request directly to Anthropic and uses the bearer token you supplied as the upstream x-api-key. In that case the token must be a valid Anthropic API key. For all non-claude-* models the token is validated against the gateway's own key and the request is routed through the internal MoE engine.
Errors
| Status | Meaning |
|---|---|
401 | Missing or invalid API key. |
503 | Model router not initialized (gateway still starting up). |
502 | Upstream provider error. |
504 | Request timed out. |