Claude Code with third-party models
Claude Code talks to an Anthropic-compatible endpoint. If you run a local gateway that speaks the same protocol, you can point Claude Code at it and choose the upstream behind it.
How the client is configured
Claude Code reads ~/.claude/settings.json. Two fields matter:
env.ANTHROPIC_BASE_URL— the host root, without/v1. Claude Code appends the path itself.env.ANTHROPIC_AUTH_TOKEN— the token the endpoint expects.
These are the client's own configuration fields. Your use of any model provider remains subject to that provider's terms.
With Relay
- Install and start Relay. It listens on
127.0.0.1:4141. - In Relay, add a provider and one or more models on the Models page.
- On the Clients / Setup page, enable Claude Code. Relay writes
ANTHROPIC_BASE_URLand the local token intosettings.json, keeping a backup and detecting changes made outside Relay. - Restart Claude Code. Quit Relay from the tray when you are done so the configuration is restored.
The same switch also handles Codex, which uses ~/.codex/config.toml and OpenAI
Responses. Both clients can be pointed at Relay at the same time.
Doing it by hand
If you prefer not to run a gateway, you can edit settings.json yourself and point
ANTHROPIC_BASE_URL directly at a provider that offers an Anthropic-compatible endpoint.
You are responsible for checking that the provider supports the Messages API, tool use and the
features you rely on.
Relay is an independent project, not affiliated with Anthropic. "Claude Code" is used only to describe client compatibility.