For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Claude Code
Configure Claude Code CLI to use agentgateway
Configure Claude Code, the AI coding CLI by Anthropic, to route LLM requests through your agentgateway proxy.
Before you begin
- Install the
agentgatewaybinary. - Install the Claude Code CLI (
npm install -g @anthropic-ai/claude-code). - Get an Anthropic API key from the Anthropic Console.
Configure agentgateway
Start agentgateway with an Anthropic backend configuration.
Export your Anthropic API key.
export ANTHROPIC_API_KEY="sk-ant-your-key-here"Create a configuration file with the Anthropic provider. The wildcard
*model name accepts any model. Claude Code sends the model in each request, so you do not need to pin a specific model.cat > config.yaml << 'EOF' # yaml-language-server: $schema=https://agentgateway.dev/schema/config llm: models: - name: "*" provider: anthropic params: apiKey: "$ANTHROPIC_API_KEY" EOFStart agentgateway.
agentgateway -f config.yaml
Configure Claude Code
Set the ANTHROPIC_BASE_URL environment variable to point Claude Code at your agentgateway instance.
export ANTHROPIC_BASE_URL="http://localhost:4000"Verify the connection
Send a single test prompt through agentgateway.
claude -p "Hello"Example output:
Hello! How can I help you today?Verify that the request appears in the agentgateway logs.
Example output:
info request gateway=default/default listener=llm route=internal/model:* endpoint=api.anthropic.com:443 http.method=POST http.path=/v1/messages http.status=200 protocol=llm gen_ai.operation.name=chat gen_ai.provider.name=anthropic gen_ai.request.model=claude-haiku-4-5-20251001 gen_ai.usage.input_tokens=14 gen_ai.usage.output_tokens=9 gen_ai.request.max_tokens=50 duration=1687msIf you see an error like
API Error: 400 context_management: Extra inputs are not permitted, Claude Code is sending experimental beta parameters that agentgateway does not yet support. Disable experimental betas and retry the request.export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 claude -p "Hello"Optionally, start Claude Code in interactive mode with all traffic routed through agentgateway.
claudeAll requests, including prompts, tool calls, and file reads, flow through agentgateway.