Point Claude Code at One Custom Endpoint
Claude Code can connect to a custom API endpoint through environment variables. The important detail is protocol compatibility: although Vana API provides an OpenAI-compatible interface, Claude Code uses the Anthropic Messages protocol. Vana API also supports that protocol, so you can point the CLI at https://api.vanaapi.com without adding a separate translation proxy.
This walkthrough configures one terminal session first. That makes it easier to verify the connection before changing your everyday setup.
§ 1. Prepare your account and API key
Create a Vana API account, generate an API key, and check that your account has available credit. Usage is billed per real token, with no monthly fee.
Keep the key out of source files, shared terminal transcripts, and version control. You will also need the exact API model identifier shown by Vana API. A display name such as Claude Sonnet 5.5 is useful when choosing a model, but do not assume its spelling is the identifier your requests must send.
These steps assume Claude Code is already installed and that you are using Bash, Zsh, or a similar shell on macOS, Linux, or WSL.
§ 2. Remove conflicting settings from this session
Open a fresh terminal. If you previously configured Claude Code for another provider, inspect your environment and shell startup files before proceeding. Existing credentials or provider-selection variables can make a routing problem look like an endpoint failure.
For this direct gateway setup, clear the following variables in the current shell:
unset ANTHROPIC_API_KEY CLAUDE_CODE_USE_BEDROCK CLAUDE_CODE_USE_VERTEX CLAUDE_CODE_USE_FOUNDRY
This does not delete saved credentials or modify your startup files. It only removes those environment variables from this shell and the processes you launch from it.
§ 3. Set the endpoint, token, and model
Run the following commands, replacing both placeholder values before use:
1 export ANTHROPIC_BASE_URL='https://api.vanaapi.com' 2 export ANTHROPIC_AUTH_TOKEN='YOUR_VANA_API_KEY' 3 export ANTHROPIC_MODEL='EXACT_MODEL_ID_FROM_VANA'
Use the base URL, not a complete request URL. Do not append /v1/messages. Claude Code constructs the Messages request path itself. Likewise, do not substitute an OpenAI chat-completions URL simply because the service also supports OpenAI clients.
ANTHROPIC_AUTH_TOKEN supplies bearer authentication for this configuration. Treat its value as a secret. Typing a literal key into an export command can leave it in shell history; on a shared machine, use your established secret-loading method instead.
§ 4. Launch Claude Code and test a small request
Change into a project directory you trust, then start Claude Code from the same terminal:
claude
Ask a small question that does not require repository access, such as: “Reply with one short sentence confirming you can respond.” Keep the first test simple so that file permissions, tools, and long context do not complicate diagnosis.
Use Claude Code’s /status command to inspect the configuration information your installed version exposes. Then check Vana API’s usage records for the corresponding request. A successful reply confirms connectivity; a matching usage entry gives additional evidence that traffic reached the intended account.
§ 5. Check common failures
- Authentication failure: Confirm that the key is valid, has no accidental whitespace, and belongs to the intended account. Recheck any competing credential settings.
- Model not found: Copy the exact API identifier from Vana API rather than deriving one from a display name. Confirm that the model is available to your account.
- Not found or unexpected response format: Check the base URL and remove any manually appended API route.
- Unexpected routing: Confirm that you launched Claude Code after exporting the variables. A process already running will not inherit later shell changes.
- Basic chat works but tools fail: Test a small, read-only repository task next. Protocol support alone does not guarantee identical behavior for every client feature.
§ 6. Make the working configuration reusable
Once the test succeeds, put the non-secret exports in a dedicated launcher or your preferred shell configuration. Load the token through a local secret mechanism, and keep credentials outside the repository.
A dedicated launcher is useful when you also use other providers: it keeps the endpoint and model choice explicit without changing every terminal session. After editing persistent settings, open a new shell and repeat the small verification request.