Server architecture
The proxy server is built on Node.js’s native HTTP server and runs on port 18080 by default (configurable viaCOPILOT_PROXY_PORT).
API endpoints
POST /v1/messages
The main endpoint for chat completions. Accepts Anthropic Messages API format and returns responses in the same format.The Anthropic model name (e.g.,
claude-opus-4-6, claude-sonnet-4-5). The proxy automatically maps this to the corresponding Copilot model.Array of message objects with
role and content fields. Supports user and assistant roles.System prompt as a string or array of content blocks.
Maximum number of tokens to generate in the response.
Sampling temperature between 0 and 1. Higher values make output more random.
Nucleus sampling parameter. Alternative to temperature.
Whether to stream the response using Server-Sent Events.
Array of tool definitions in Anthropic format. The proxy translates these to OpenAI function calling format.
Array of strings that will stop generation when encountered.
Example request
Example response (non-streaming)
Unique identifier for the message.
Always
"message" for successful responses.Always
"assistant" for responses.The model name from the request.
Array of content blocks. Each block has a
type field (e.g., "text", "tool_use").Reason the model stopped:
"end_turn", "tool_use", or "max_tokens".Token usage statistics with
input_tokens and output_tokens fields.Streaming response
Whenstream: true, the endpoint returns Server-Sent Events:
GET /health
Health check endpoint that returns the server status.Example response
GET /models
Returns a list of available models in OpenAI format.Example response
POST /count_tokens
Estimates token count for a request. Uses a rough heuristic of ~4 characters per token.Example request
Example response
Authentication
The proxy loads the GitHub OAuth token from the auth file at startup:Error handling
The proxy translates GitHub Copilot errors to Anthropic’s error format:The proxy automatically handles token refresh and retry logic for transient errors.
Web search support
When a request includes theweb_search_20250305 tool, the proxy:
- Adds a
web_searchfunction tool to the Copilot request - Executes searches using Brave Search API or DuckDuckGo
- Feeds results back to the model
- Repeats until no more searches are needed
Configuration
Port to run the proxy server on.
Path to the authentication file.
API key for Brave Search (optional, improves web search quality).
Maximum number of search results to return per query.
Set to
"1" to enable debug logging for streaming responses.