Claude Code does not become an OpenAI Chat Completions client when you set ANTHROPIC_BASE_URL. For that setting, its gateway must speak Anthropic Messages. Claude Code also has separate connection modes for Amazon Bedrock and Google Cloud’s Agent Platform.
Match Claude Code’s request format
| Claude Code connection | Format sent by Claude Code | What the endpoint must accept |
|---|---|---|
ANTHROPIC_BASE_URL | Anthropic Messages | POST /v1/messages |
| Amazon Bedrock mode | Bedrock InvokeModel | Bedrock’s provider-specific request format |
| Google Cloud Agent Platform mode | Vertex rawPredict | Agent Platform’s provider-specific request format |
| OpenAI-compatible Chat Completions | POST /v1/chat/completions | Use a client or adapter that explicitly supports this format |
A service that only exposes /v1/chat/completions does not, by itself, satisfy Claude Code’s Anthropic Messages connection. The formats use different paths and request bodies.
Choose the route from the endpoint you have
- Your endpoint offers only OpenAI Chat Completions: connect it from software that documents OpenAI-compatible Chat Completions. See the ChinaGenAI endpoint compatibility notes.
- You want to use Claude Code: confirm that your gateway exposes Anthropic Messages, or configure Claude Code’s documented Bedrock or Agent Platform mode.
- Your gateway translates between formats: confirm that it accepts Anthropic Messages from Claude Code and forwards the required request fields, tool calls and streaming behavior to its upstream. “OpenAI-compatible” alone does not prove this translation is available.
HTTP_PROXY and HTTPS_PROXY route network traffic through an HTTP proxy. They do not translate a Chat Completions request into Anthropic Messages.
Separate a path error from a credential error
POST /v1/messagesreturns 404: check whether that server actually implements Anthropic Messages at the configured base URL. A Chat Completions-only service uses a different route. This points to a protocol or path check; it does not identify the cause by itself.- The model is missing from
/model: model discovery is separate from a chat request. Claude Code’s gateway model discovery is opt-in and usesGET /v1/modelsfor an Anthropic Messages gateway. An empty picker alone does not prove that a configured inference route is broken. - HTTP 401: inspect the credential variable and authentication header required by that gateway. Do not rotate a key to fix a request sent to the wrong protocol or path.
- HTTP 400 involving tools or message fields: preserve the redacted request shape and check what the adapter forwards. Claude Code adds fields beyond a basic text exchange, and an adapter may not support every feature.
Keep the method, path and response status, but redact authorization headers, tokens, query values and private hostnames before sharing a capture. For a saved response, use the raw response checklist and API error guide.
Model discovery is optional
Claude Code can request a gateway model list when CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 is enabled. The official guide says discovery applies to the Anthropic Messages format; Bedrock and Agent Platform modes use their provider-specific behavior. Check the exact request in the gateway log before treating a failed discovery request as a failed chat route.
To prepare a standard OpenAI Chat Completions body without sending it, use the local request builder. It cannot convert that body into Anthropic Messages.
Official references
Claude Code: Gateway compatibility and API formats
Claude Code: Connect to an LLM gateway
Official Claude Code gateway documentation checked 27 October 2026. No key, Claude Code session or model request was used.
Exact symptom wording and source
Use the quoted text to locate the relevant check. Providers and clients can phrase the same failure differently; compare the complete response before applying a fix.
Reported text:
Claude Code POST /v1/messages returns 404 on an OpenAI-compatible APIClaude Code documents Anthropic Messages, Bedrock and Vertex gateway formats. A 404 is a reason to verify the actual path and format; it does not identify the cause or prove a current product defect.
Inference requests post to /v1/messages?beta=true
Claude Code gateway compatibility documentation, checked 27 October 2026