Skip to main content

Endpoints and Headers

An endpoint is a URL path on a server, and a header is a named value that a request carries. Claude Code calls the model server and a few account servers, and it adds headers to each request. If you run Claude Code behind a proxy, the proxy must pass anthropic-version and anthropic-beta on without a change.

Base URL variables pick the server, and ANTHROPIC_CUSTOM_HEADERS adds headers. The switches are CLAUDE_CODE_GATEWAY_HINT_HEADERS, CLAUDE_CODE_ATTRIBUTION_HEADER=0, and CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1. The model list is cached in ~/.claude/cache/gateway-models.json.

Model Endpoints​

Source: Gateway Compatibility Guide, and Probes for cache_touch.

PathStatusWhat It Does
/v1/messages?beta=trueDocumentedSends the model request.
/v1/messages/count_tokensDocumentedCounts tokens. Without it, Claude Code estimates from the number of characters.
/v1/messages/cache_touchUndocumentedClaude Code calls it every 30 seconds (10 to 120) to keep the prompt cache warm. It needs a subscriber login and the cache-keepalive-2026-09-03 beta.
/v1/modelsDocumentedLists the models for the /model picker, only with CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1.
HEAD /api/helloDocumentedWarms up the connection. Claude Code skips it when an HTTP proxy or a client certificate is set.
/model/{model}/invoke and /model/{model}/invoke-with-response-streamDocumentedThe Amazon Bedrock format, chosen with ANTHROPIC_BEDROCK_BASE_URL.
:rawPredict and :streamRawPredictDocumentedThe Google Cloud Agent Platform format, chosen with ANTHROPIC_VERTEX_BASE_URL.

Account and Service Endpoints​

These paths are strings in the program. The docs do not describe them, except the OpenTelemetry row. The use of a path is a guess from its name.

PathStatusLikely Use
/v1/oauth/token, /api/oauth/profile, /api/oauth/usage, /api/oauth/account/settingsUndocumentedSign-in tokens, the profile, plan usage, and account settings.
/api/claude_code/policy_limitsUndocumentedThe limits of your organization, cached in policy-limits.json.
/api/claude_code/organizations/metrics_enabled, /api/claude_code/notification/preferences, /api/claude_code/skillsUndocumentedThe metrics switch of the organization, notification settings, and synced skills.
/api/event_logging/v2/batchUndocumentedEvent logging by Anthropic.
/v1/metrics, /v1/logs, /v1/tracesDocumentedOpenTelemetry export. See Monitoring.
/api/claude_cli_feedback, /api/claude_code_shared_session_transcriptsUndocumentedFeedback and shared transcripts.
/v1/code/sessions, /v1/code/triggers, /v1/code/github/*, /v1/code/agent-proxyUndocumentedCloud sessions, routines, and GitHub helpers.
/v1/ultrareview/quota, /v1/ultrareview/preflightUndocumentedThe command claude ultrareview.
/api/model_selector/{id}, /api/organization/claude_code_first_token_dateUndocumentedData for the model picker and the date of first use.
/api/ws/speech_to_text/voice_streamUndocumentedVoice dictation.
/api/frame/*, /v1/design/*UndocumentedArtifacts and Claude Design.

The program also holds an Anthropic SDK client with paths such as /v1/agents, /v1/skills, /v1/vaults, and /v1/organizations/*. They belong to the SDK code, and the Claude Code loop does not call them. The program names these hosts: code.claude.com, claude.ai, claude.com, api.anthropic.com, platform.claude.com, www.anthropic.com, support.claude.com, downloads.claude.ai, and mcp-proxy.anthropic.com.

Request Headers​

Source: Gateway Compatibility Guide. Header names are not case-sensitive.

HeaderStatusMeaning
Authorization, x-api-keyDocumentedThe credential.
anthropic-versionDocumentedThe API version, 2023-06-01.
anthropic-betaDocumentedThe list of beta values. See Betas.
x-claude-code-session-idDocumentedOne value for each session.
x-claude-code-agent-id, x-claude-code-parent-agent-idDocumentedThe subagent that sent the request, and its parent.
x-claude-code-request-classDocumentedThe kind of request: main, subagent, workflow, compaction, or auxiliary.
x-claude-code-agent-typeDocumentedThe kind of agent: Explore, Plan, general-purpose, custom, teammate, or fork.
x-claude-code-compaction, x-claude-code-context-compactedDocumentedMarks a compaction request, and the first request after one.
x-claude-code-prev-tool-durationsDocumentedThe run time of the last tool batch, such as Bash=742;Read=9, with at most 32 entries and 4 KB.
x-claude-code-prompt-idDocumentedA random UUID for the user prompt, from 2.1.283.
anthropic-workspace-idDocumentedNeeded on Claude Platform on AWS.
ANTHROPIC_CUSTOM_HEADERSDocumentedAn env var for extra headers, one Name: value on each line. It is not a header itself.
x-app, anthropic-client-platform, X-Stainless-*, X-Trusted-Device-Token, x-organization-uuidUndocumentedNames in the program. No source states their rules.

The hint headers (x-claude-code-request-class and the next four rows) go out on a direct connection to the Anthropic API. On a custom base URL they need CLAUDE_CODE_GATEWAY_HINT_HEADERS=1. Setting it to 0 stops them everywhere.

Response Headers Claude Code Reads​

HeaderStatusUse
retry-afterDocumentedA number of seconds. A value above 60 stops the retries unless CLAUDE_CODE_RETRY_WATCHDOG is set.
x-should-retryDocumentedtrue or false. It is one input to the retry decision.
anthropic-ratelimit-unified-*DocumentedPlan usage and limits for claude.ai sign-ins.
content-typeDocumentedtext/event-stream, or application/vnd.amazon.eventstream on Bedrock.

Attribution Block​

The first block of system is a text line that starts with x-anthropic-billing-header:. The docs say the block holds the client version and a fingerprint of the conversation (Gateway Compatibility Guide). The field names below come from the program.

FieldStatusMeaning
cc_versionUndocumentedThe client version.
cc_entrypointUndocumentedWhere Claude Code runs, such as cli, sdk-cli, or claude-vscode.
cc_workload, cc_is_subagentUndocumentedThe workload tag (--workload), and a flag for subagents.
cc_prev_req, cc_prompt_id, cc_turn_origin, cc_prompt_index, cc_turn_indexUndocumentedRequest and turn tracking, only on the Anthropic API.
cc_gateway, cc_project, cc_project_srcUndocumentedTags for the gateway and the project.

CLAUDE_CODE_ATTRIBUTION_HEADER=0 removes the block. The api.anthropic.com server strips it when it is the first and only block of its entry.

Example​

Keep the hint headers on a custom gateway and read them there.

Send hint headers to a gateway
export ANTHROPIC_BASE_URL=https://gateway.example.com
export CLAUDE_CODE_GATEWAY_HINT_HEADERS=1
claude -p "hi"

The gateway then sees x-claude-code-request-class: main and the other hint headers on each request.

How It Works​