Claude Code natively uses Anthropic API semantics.OpenAI Compatible is not equal to Anthropic Compatible. Before configuring, you must confirm that the current service clearly provides a Claude Code or Anthropic protocol compatible entry; you cannot directly fill in the OpenAI Base URL with Claude Code just because the model name contains Claude.
Check before you start
- Confirm the protocol and private address currently used by Claude Code in the AIFast API documentation or customer service.
- Confirm that the service provides an Anthropic-compatible API, not just an OpenAI Compatible API.
- Create an independent Key for Claude Code and do not share it with the production service.
Configuration steps
Common configurations of Claude Code are completed through environment variables. The specific variables and authentication methods should be subject to the current Claude Code official documents and AIFast access instructions. Typical inspection items include:
ANTHROPIC_BASE_URL
ANTHROPIC_AUTH_TOKEN Or the corresponding authentication variable
Default model and small model settings
After the configuration is completed, open a new terminal and confirm whether the variable exists. Do not print the complete Key directly:
test -n "$ANTHROPIC_BASE_URL" && echo "Base URL Already set"
test -n "$ANTHROPIC_AUTH_TOKEN" && echo "Authentication variables are set"
Then enter a test directory that does not contain sensitive code and perform a short task:
Read in the current directory README,and summarized in three key points,Do not modify the file。
Verify read-only tasks first, then verify writing files and executing commands.
FAQ
Returns 404 or API format error
The most common reason is to put OpenAI's /v1/chat/completions The address is given to clients that require the Anthropic Messages format. Check the dedicated Base URL and protocol, and do not change the Key repeatedly.
Can chat but the tool call is abnormal
An intermediate compatibility layer may only convert text requests, without fully converting tool calls, streaming events, or usage fields. Reading files, changing files, executing commands and long tasks must be tested before production use.
Environment variables do not take effect after modification
Close and reopen the terminal and confirm that the configuration is written to the startup file used by the current shell. Do not set conflicting addresses in multiple configuration files at the same time.
Next step
After completing the basic configuration, continue pressingClaude Code gateway API acceptance and troubleshooting checklistVerify Messages paths, continuous streaming output, real tool calls, long context, caching and error forwarding respectively. Do not use a normal conversation to successfully replace the Agent's ability acceptance.
After confirming protocol compatibility, set independent usage limits and project-level security rules for Claude Code. Private repositories, key files, and customer data should be explicitly excluded.