Skip to main content

API Overview

Claude Code Router Server provides a complete HTTP API with support for:

  • Messages API: Message interface compatible with Anthropic Claude API
  • Chat Completions API: OpenAI-compatible chat interface
  • Responses API: OpenAI-compatible typed input/output interface
  • Configuration API: Read and update server configuration
  • Logs API: View and manage service logs
  • Tools API: Calculate token counts

Basic Information

Base URL: http://localhost:3456

Authentication: API key via Authorization: Bearer or x-api-key

curl -H "x-api-key: your-api-key" http://localhost:3456/api/config

API Endpoints

Messages

EndpointMethodDescription
/v1/messagesPOSTSend message (compatible with Anthropic API)
/v1/messages/count_tokensPOSTCount tokens in messages
/v1/chat/completionsPOSTOpenAI Chat Completions (alias: /chat/completions)
/v1/responsesPOSTOpenAI Responses (alias: /responses)

Configuration Management

EndpointMethodDescription
/api/configGETGet current configuration
/api/configPOSTUpdate configuration
/api/transformersGETGet list of available transformers

Log Management

EndpointMethodDescription
/api/logs/filesGETGet list of log files
/api/logsGETGet log content
/api/logsDELETEClear logs

Service Management

EndpointMethodDescription
/api/restartPOSTRestart service
/uiGETWeb management interface
/ui/GETWeb management interface (redirect)

Authentication

API Key Authentication

Add API Key in request header:

curl -X POST http://localhost:3456/v1/messages \
-H "x-api-key: your-api-key" \
-H "content-type: application/json" \
-d '...'

Streaming Responses

The Messages, Chat Completions, and Responses APIs support Server-Sent Events. Each route emits its native client protocol: Anthropic event names, Chat chat.completion.chunk records ending in [DONE], or ordered response.* events ending in response.completed/response.failed.

curl -X POST http://localhost:3456/v1/messages \
-H "x-api-key: your-api-key" \
-H "content-type: application/json" \
-d '{"stream": true, ...}'

Streaming response format:

event: message_start
data: {"type":"message_start","message":{...}}

event: content_block_delta
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"}}

event: message_stop
data: {"type":"message_stop"}