Introducing our most accurate /search yet. Read the announcement →

How to Use GPT, Gemini, and Grok Models Inside Claude Code with CLI Proxy

placeholderRichard Oliver Bray
Aug 04, 2026

TL;DR:

  • CLI Proxy is a local proxy server that lets you run GPT, Gemini, or Grok models inside Claude Code by pointing ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN at localhost:8317
  • It logs in through each provider's OAuth flow, so requests draw from your existing subscription instead of pay-as-you-go API credits
  • Each Claude Code tier (ANTHROPIC_DEFAULT_OPUS_MODEL, SONNET, HAIKU) can map to a different model from a different provider
  • Skills, subagents, reasoning efforts, and plan mode all keep working because translation happens at the API layer
  • The proxy stores multiple OAuth tokens per provider and rotates between them (default: round-robin) to spread usage across accounts
  • Exposing Claude models to other CLIs technically violates Anthropic's ToS; using non-Claude models inside Claude Code (the direction covered here) doesn't

Claude Code is my pick for the best AI coding tool right now, and it expects you to use Claude models, which cost more than the competition and come with less generous subscription limits. There's a way around that: CLI Proxy, a local proxy server that lets you run GPT, Gemini, or Grok models inside Claude Code, on your existing subscriptions.

It also switches between multiple accounts for the same provider automatically, so you get more out of your usage limits. Here's how the whole thing works.

Claude Code running a GPT model

This is Claude Code, except the model in the status line is gpt-5.6-terra instead of a Claude model. Ask it don't use any skills, what ai model is this and who was it built by and it answers GPT-5.6 Terra, built by OpenAI.

Claude Code running gpt-5.6-terra with low effort, answering "Model: GPT-5.6 Terra. Built by OpenAI." to a prompt asking what model it is

You can swap between models, Terra, Luna, and Sol here, and change the reasoning effort level, without leaving Claude Code. The API Usage Billing notice is a red herring: the requests come out of your provider subscription rather than pay-as-you-go API credits, for reasons that make sense once you see how the authentication works.

Everything else about Claude Code behaves normally. Giving it a real task, search for information about Opus 5 and present it to me in an Anthropic style HTML page, it loads a skill, thinks with medium effort, and runs the task with full subagent support.

Claude Code loading the brainstorming skill and thinking with medium effort while running on gpt-5.6-sol

Part of that task was gathering current information about a model that didn't exist when the GPT model was trained, which it did through the new and improved Firecrawl search API. Search is one of the endpoints that works keyless, so there's nothing to sign up for to try it, though a free API key raises the rate limits and adds credits.

Search is what this run needed; /scrape returns clean markdown from a single URL, and /interact handles pages that need clicks or logins before you can extract.

The result was a full status page, built by an OpenAI model, researched with Firecrawl, orchestrated entirely by Claude Code. You can see the page it generated, complete with a lineup map, an evidence ledger, and a timeline. It's demo output rather than a reference, so none of it has been fact-checked.

A generated status page titled "What Anthropic actually announced", describing Claude Opus 5 replacing Claude Opus 4.8 and where it sits in Anthropic's lineup

That whole run cost 11% of the weekly subscription limit. Claude Code reported a much higher context figure than that, which is a small display bug in the setup rather than real usage.

Installing CLI Proxy

On a Mac, CLI Proxy installs through Homebrew:

brew install cliproxyapi
brew services start cliproxyapi

Linux has a one-click installer script and an AUR package, Windows has a release binary plus a desktop GUI, and there's a Docker image if you'd rather run this on a separate VPS. All four paths are in the quick start docs.

Editing the CLI Proxy config

Where the config file lives depends on how you installed it. With Homebrew on Apple Silicon it's at /opt/homebrew/etc/cliproxyapi.conf. Two things in there need changing.

# /opt/homebrew/etc/cliproxyapi.conf
 
port: 8317
 
remote-management:
  # Password for the web UI. Put a plaintext value here and it gets
  # hashed on startup.
  secret-key: "something-you-will-remember"
 
# Authentication directory (supports ~ for home directory)
auth-dir: "~/.cli-proxy-api"
 
# API keys for authentication
api-keys:
  - "sk-your-api-key-1"

The secret-key is the password you'll use to log into CLI Proxy's web view. It can be anything, and it gets hashed inside the config the first time you log in, so it won't sit there in plaintext.

The api-keys list is the more interesting one. This is the token that gets bundled with every request Claude Code sends to the proxy. Claude Code expects a token to exist, so you give it one of these, and CLI Proxy checks the incoming token against this list before doing anything real. It's what stops any other app on your machine from hitting the proxy port and burning through your usage.

You can generate a proper random value for it rather than making one up:

openssl rand -hex 32

Once the config is saved, restart the service to pick it up:

brew services restart cliproxyapi

Logging in a provider

Now go to http://localhost:8317 and log in with the password you set as your secret key. That opens the CLI Proxy API Management Center, and from the dashboard, OAuth Login lists every provider you can authenticate with: Codex, Anthropic, Antigravity, and Kimi.

The CLI Proxy API Management Center's OAuth Login page listing Kimi OAuth, Codex OAuth, Anthropic OAuth, and Antigravity OAuth, each with its own login button

Starting a Codex login opens the normal OAuth flow: pick your account, approve it, done. The page itself doesn't change afterwards, so to confirm it worked, head to Auth Files, where the credential shows up with its provider, size, and health.

The Auth Files page in CLI Proxy's management center showing a saved Codex credential with size, modified date, success and failure counts, and a health strip

This is also where the multi-account part starts to matter. Nothing stops you logging in several times with different accounts for the same provider, and each one lands here as its own credential.

Pointing Claude Code at the proxy

The last step is configuring your client. Claude Code reads its endpoint and model choices from environment variables, so a shell alias is enough:

# config.fish
 
alias ccx='ANTHROPIC_BASE_URL=http://localhost:8317 \
  ANTHROPIC_AUTH_TOKEN=sk-your-api-key-1 \
  ANTHROPIC_DEFAULT_OPUS_MODEL=gpt-5.6-terra \
  ANTHROPIC_DEFAULT_SONNET_MODEL=gpt-5.6-terra \
  ANTHROPIC_DEFAULT_HAIKU_MODEL=gpt-5.6-luna \
  ANTHROPIC_DEFAULT_FABLE_MODEL=gpt-5.6-sol \
  CLAUDE_CODE_SUBAGENT_MODEL=gpt-5.6-terra \
  claude'

Here's what each variable does:

  • ANTHROPIC_BASE_URL points Claude Code at the local proxy instead of Anthropic's servers.
  • ANTHROPIC_AUTH_TOKEN is one of the values from the api-keys list you set earlier.
  • ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and ANTHROPIC_DEFAULT_FABLE_MODEL each map one Claude Code model tier onto the model you actually want running there.
  • CLAUDE_CODE_SUBAGENT_MODEL covers what subagents get.

They're all separate variables, so nothing stops you pointing each tier at a different provider.

You can see the result in Claude Code's own model picker, which still thinks it's offering you Claude tiers and lists a GPT model against each one:

Claude Code's Select model menu listing gpt-5.6-terra as the Custom Opus model, gpt-5.6-sol as the Custom Fable model, gpt-5.6-terra as the Custom Sonnet model, and gpt-5.6-luna as the Custom Haiku model

If you're not sure what model names to put in those variables, ask the proxy. It exposes an OpenAI-compatible models endpoint, and piping it through jq makes it readable:

curl -s http://localhost:8317/v1/models \
  -H "Authorization: Bearer sk-your-api-key-1" | jq

Reload your shell config, run the alias, and Claude Code starts up on a GPT model. Claude Code isn't the only option either: CLI Proxy has client configuration docs for Codex, Factory Droid, and OpenCode too.

If you have several clients pointed at the proxy, give each one a different API key from the list. That way the proxy's logs and quota tracking can tell them apart.

One thing worth flagging: this works in the other direction as well. You could sign in with Anthropic OAuth and use your Claude subscription inside Codex. That technically goes against Claude's terms of service though, so it's not something to recommend.

How CLI Proxy translates between APIs

At a high level, CLI Proxy is a proxy server that lets a client like Claude Code read the API format of a different model.

Normally, a prompt in Claude Code goes to Anthropic's servers and comes back in Anthropic's API format, which Claude Code knows how to read. Send a prompt from Codex CLI and it goes to OpenAI's servers and comes back in OpenAI's format, which Claude Code can't read. Same request, incompatible envelope.

CLI Proxy sits between the client and the model provider's servers and translates in both directions: your request becomes something the provider understands, and the provider's response becomes something the client understands.

A diagram titled "How CLI Proxy works" showing Claude Code and Codex CLI both routing through a CLI Proxy box at localhost:8317, which connects to both Anthropic servers and OpenAI servers, with a crossed-out direct line from Claude Code to OpenAI servers

Because the translation happens at the API layer, everything built on top of the API survives the trip. That's why reasoning efforts, subagents, and Claude Code workflows all still work when the model on the other end is GPT.

How CLI Proxy handles authentication

The more interesting half of this is how CLI Proxy handles auth.

When you log into a model provider's website to use your subscription, you get back a token that only that provider accepts. Tokens aren't interchangeable, which is normally the end of the conversation.

When you log in through CLI Proxy, it grabs that token and saves it in its own auth directory. So a request from Claude Code carries the dummy token from CLI Proxy's config, because Claude Code insists on a token existing. CLI Proxy checks that token against its list, and if it matches, makes the real request using the real provider token it's holding.

A diagram titled "How CLI Proxy handles auth" showing Claude Code sending a dummy token to CLI Proxy, which acts as an auth vault, with the model provider's real token saved to that vault and labeled "tied to this model only"

This is why the multi-account thing works. Since the proxy owns the real credentials, it can hold several accounts for the same provider and pick whichever token it likes per request. The default strategy is round-robin, which spreads load across accounts to get the most out of your rate limits. There's also fill-first if you'd rather exhaust one account before moving to the next, plus optional session affinity to bind a conversation to one credential.

Why not just use GLM or Kimi directly

This isn't an entirely new technique. Kimi and GLM already let you use their models inside Claude Code, and cc-mirror lets you create isolated versions of Claude Code with custom providers.

The catch with those is that you're locked into one provider. You can't make your Fable model GPT, your Opus model GLM, and your Sonnet model Kimi. You use that provider's models for everything, or you use something else.

And if you wanted to run this through Codex instead of Claude Code, some of those integrations won't work at all, because they don't support the API Codex speaks. Which is why Theo and even Tibo from OpenAI recommend CLI Proxy for running GPT models inside Claude Code.

One local proxy, one config file, and the model behind each Claude Code tier becomes something you choose rather than something you inherit.

Frequently Asked Questions

Can you use GPT or Gemini models inside Claude Code?

Yes. Claude Code reads two environment variables, ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, so if you point the base URL at a local proxy that speaks Anthropic's API format, Claude Code can't tell the difference. CLI Proxy is that proxy: it translates your request into the target provider's format, calls them, and translates the response back.

What is CLI Proxy API?

CLI Proxy API (CLIProxyAPI) is an open source local proxy server that sits between a coding CLI and a model provider's servers. It converts requests into the format the provider expects and converts responses back into the format the client expects, so Claude Code, Codex, Droid, and OpenCode can all talk to providers they weren't built for.

How do I install CLI Proxy on macOS?

brew install cliproxyapi then brew services start cliproxyapi. The config file lands at $(brew --prefix)/etc/cliproxyapi.conf, typically /opt/homebrew/etc/cliproxyapi.conf on Apple Silicon. Linux has a one-click installer script and an AUR package, Windows has a release binary and a desktop GUI, and there's a Docker image if you want it on a VPS.

Do I need API credits to use CLI Proxy?

No. CLI Proxy logs in through each provider's OAuth flow, so it uses your existing subscription rather than pay-as-you-go API billing. Claude Code may display an API usage billing notice because it thinks it's talking to a normal API endpoint, but the usage is drawn from your subscription limits.

Can I map each Claude Code model tier to a different provider?

Yes, and this is the main thing CLI Proxy does that per-provider integrations don't. Each tier is a separate environment variable, so ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_DEFAULT_HAIKU_MODEL can each point at a different model from a different provider.

Do Claude Code skills and subagents still work with a non-Claude model?

Yes. Because CLI Proxy translates at the API layer rather than intercepting the client, everything Claude Code builds on top of the API keeps working: skills load, subagents spawn, reasoning efforts pass through, and plan mode behaves normally.

Why can I have multiple accounts for the same provider in CLI Proxy?

CLI Proxy stores each provider's real OAuth token in its own auth directory and hands the client a dummy token instead. Since the proxy owns the real credentials, it can hold several for the same provider and pick one per request. The default routing strategy is round-robin, which spreads usage across accounts.

Is using a Claude subscription inside another CLI against Anthropic's terms?

CLI Proxy can log in with Anthropic OAuth and expose Claude models to clients like Codex, but doing that technically goes against Claude's terms of service, so it isn't recommended. Using non-Claude models inside Claude Code, which is the direction covered here, doesn't have that problem.

How do I see which models CLI Proxy is exposing?

Hit the proxy's models endpoint with one of the API keys from your config: curl -s -H "Authorization: Bearer <your-api-key>" http://localhost:8317/v1/models | jq. Whatever comes back is what you can put in the ANTHROPIC_DEFAULT_*_MODEL variables.

placeholder
Richard Oliver Bray @richobray
Developer Experience Engineer at Firecrawl
About the Author
Richard Oliver Bray is a Developer Experience Engineer at Firecrawl. He spent his first years as a full stack engineer before moving into developer education, later working as a Developer Advocate at Better Stack and authoring video courses for platforms like Treehouse and newline, teaching Node.js, TypeScript, and GraphQL to thousands of developers.