Configure Claude Code to send its requests to FlexInference, which serves the Anthropic Messages API.
You will never see or handle my API key. Claude Code reads it from the `ANTHROPIC_AUTH_TOKEN` environment variable, and I export that myself. Do not ask me for the key, do not write it into any file, and do not read it from my environment.
Ask me whether to configure this globally or for one project, then edit `~/.claude/settings.json` or `.claude/settings.json` accordingly. Create the file if it does not exist, and preserve every setting already in it.
Add this `env` block, merging into any existing `env` rather than replacing it. Note that it carries no credential:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.flexinference.com",
"ANTHROPIC_MODEL": "claude-opus-5",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5",
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
}
}
Then print this line for me to run in the shell I start Claude Code from. Do not run it and do not ask for the value:
export ANTHROPIC_AUTH_TOKEN=<paste your key here>
Rules that matter, do not deviate:
- `ANTHROPIC_BASE_URL` must NOT end in `/v1`. Claude Code appends `/v1/messages` itself.
- The credential must arrive as `ANTHROPIC_AUTH_TOKEN`, never `ANTHROPIC_API_KEY`. The first sends `Authorization: Bearer`, which FlexInference requires. The second sends `x-api-key`, which it refuses with `401 missing_api_key`.
- Both model variables must be `claude-*` slugs. Claude Code sends Anthropic-native fields such as `output_config` on every request, and FlexInference refuses to mistranslate them onto a non-Claude model.
- `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` must be `"1"`. Without it Claude Code sends experimental beta fields such as `context_management`, FlexInference does not forward the `anthropic-beta` headers they need, and every request fails with `400 context_management: Extra inputs are not permitted`.
- Do not add a retry setting. Claude Code retries on its own and my key may carry its own policy.
Finally, tell me that Anthropic must be servable on my FlexInference organization. On BYOK that means an Anthropic provider key on the API, then Provider keys tab. On Managed Keys it means Anthropic enabled and funded. Then start a new Claude Code session and report what you changed.