How to · Building with models

Pointing Claude Code, Codex or any tool at a different model

Your coding agent does not care which company answers it. It sends requests to an address it reads from a setting, and changing that address is the whole trick — the work is in proving the change took.

Updated 28 Sept 2026

The coding agents and editors you already use, Claude Code and Codex among them, talk to their model over one widely copied API shape. Almost all of them let you change where that API lives, which means the same tool you use every day can run against a different host, a cheaper one, or a model sitting on your own machine, without relearning anything.

For Claude Code the address is an environment variable called ANTHROPIC_BASE_URL, the credential goes in ANTHROPIC_AUTH_TOKEN, and ANTHROPIC_MODEL names the model you want. Set those three and the tool sends its requests somewhere else. Codex keeps the same two ideas in a file, ~/.codex/config.toml. The short version is a single line, openai_base_url, which moves its built-in provider to a different address. The longer version declares a provider of your own with a base_url and an env_key, which names the environment variable holding your key, and then selects it with model_provider.

Those names belong to somebody else's tool and a release can rename them. What does not change is the shape: an address, a credential, and a model name, three settings living wherever that tool keeps its settings. If yours does not match what is written above, you are still looking for those three things under different labels.

Pointing at your own machine is the easiest version of this, because Codex already knows how. It ships with ollama and lmstudio as built-in providers, so if Ollama or LM Studio is running, model_provider is the only line you need. Claude Code takes the same trip through ANTHROPIC_BASE_URL with your local address in it. Be honest with yourself about the trade, though: local models trail the frontier badly at long agentic coding, so this is the right move for private codebases, work with no connection, and experiments.

Pointing at a cheaper host is the other reason people do this, and it works because the same downloadable model is served by several companies at genuinely different prices. Every model page shows that spread, host by host. A router such as OpenRouter collapses the whole thing into one key and one address with every model behind it, which is the fastest way to try six models in an evening and the thing to move off once you have chosen.

Two cautions before you spend the afternoon. A tool tuned around one lab's models can degrade subtly against another's, because tool-calling formats and long-context behaviour differ, so judge the results on a real task before you judge them on price. And your prompts now travel to whoever you pointed at, under their policy, which is exactly what the retention and training columns on our provider pages are there to help you read.

Where next: Compare hosts for a model · What is a model router · Who can see your prompts

  1. 01

    Write down what you are using now

    Before touching anything, copy your current address and note which model the tool is set to. This sounds fussy and it is the difference between a five-minute experiment and an evening spent trying to remember what the default was.

    checkpoint · You can paste your current settings back from a note.

  2. 02

    Get a key from the provider you want to try

    Pick one provider and get an API key. Hosted first, even if your goal is local, because it isolates the question: you are testing whether your tool will talk to somewhere else at all, not whether a local server is running correctly.

    checkpoint · You have a key and the provider's base URL in front of you.

  3. 03

    Change the address and the key, and nothing else

    In Claude Code, the address lives in ANTHROPIC_BASE_URL and the credential in ANTHROPIC_AUTH_TOKEN, with ANTHROPIC_MODEL naming the model. In Codex, both live in the config file at ~/.codex/config.toml: set openai_base_url to move the built-in provider, or declare a provider of your own with base_url and env_key and select it with model_provider. Leave the model name alone for now.

    checkpoint · The tool starts without complaining about its configuration.

  4. 04

    Send one small request and prove where it went

    Ask it something trivial and watch what comes back. You are checking three things: that a response arrives, that it is not an authentication error dressed up as a model reply, and that the tool has not quietly fallen back to its default. Claude Code answers the third directly — type /status and it prints the provider and the address the session is actually using.

    checkpoint · A real answer came back, and the tool agrees it came from the provider you chose.

  5. 05

    Now change the model, one at a time

    With the wiring proven, switch the model name and try the same request again. If something breaks now you know it is the model or its name. This is also the moment to try a local server, if that was the goal all along.

    checkpoint · You know which model answered, and your note gets you back to the old setup.

What to run it with

Questions people actually ask

Will my tool stop working if the provider is incompatible?+

Usually it fails loudly, with an authentication or a model-not-found error on the first request. The failure worth guarding against is the quiet one, where the tool falls back to its own default and bills you as normal while you believe you have moved. That is what step 04 is for.

Does a different provider get the same answers?+

Not quite, and the difference is bigger for agentic work than for chat. Tool-calling formats and long-context behaviour vary between labs, so a tool tuned around one lab's models can degrade in ways that look like the model being stupid rather than the wiring being off. Judge results over a real task, not the first reply.

What happens to my prompts once I have pointed somewhere else?+

They go to whoever you pointed at, under that company's policy from then on. Our provider pages carry the retention and training answers we hold, with blanks shown as blanks, because a missing answer is our gap and never a promise.

Can I put every provider behind one address?+

Yes, and that is what a router does for you as a service. Teams often run the same idea in-house with a small self-hosted proxy such as LiteLLM, which presents one address to every tool and fans out to providers or local machines behind it, with the keys and the spend caps kept in one place.

It is an address and a key. Once the first request comes back from where you sent it, everything after that is just choosing a model.