Skip to content

LiteLLM Gateway for Claude Code, Codex, and OpenCode

Run a LiteLLM gateway on Windows to serve Claude Code, Codex CLI, and OpenCode from one place. Unified keys, spend tracking, model routing, and the common fixes.

MGMCSA Guru Team August 1, 2026 4 min read
A LiteLLM gateway serving Claude Code, Codex and OpenCode from one endpoint on Windows

If you use more than one coding agent — say Claude Code for some work, Codex CLI and OpenCode for others — configuring DeepSeek, Qwen, GLM, and Kimi separately in each gets tedious fast. LiteLLM solves that by being one gateway: configure your providers once, and serve every tool from a single endpoint, with spend tracking and budgets on top.

This is the setup on Windows and how to point each CLI at it. For single-tool setups, the per-model guides are simpler; LiteLLM shines when you run several.

What LiteLLM gives you

LiteLLM is an open-source gateway that fronts 100+ providers behind a unified API. The key feature for this use case: it can present both an OpenAI-compatible endpoint (for Codex and OpenCode) and an Anthropic-compatible one (for Claude Code), mapping both to the same underlying models. Configure DeepSeek once; use it everywhere.

Why a gateway for multiple tools

One config Define providers/keys once, not per tool
Dual format Serves OpenAI and Anthropic clients
Spend tracking See and cap usage across all tools
Model mapping Friendly names that map to any backend

Step 1: Run the gateway

LiteLLM runs via Python or Docker. On Windows, Docker Desktop or WSL is the cleanest way to keep it running as a local service. Install per the LiteLLM repository — for Docker, that’s pulling the image and providing a config file.

# illustrative — see LiteLLM docs for exact commands
pip install litellm[proxy]
litellm --config litellm.config.yaml

Step 2: Configure providers

In LiteLLM’s config, map model names to backends with their keys. For example, expose deepseek-chat, qwen3-coder-plus, and glm-5-turbo, each pointing at its provider. Keys live in the gateway config (or environment), so your tools never hold them.

Step 3: Point each tool at the gateway

Now every tool uses the same local gateway:

Claude Code (Anthropic-format endpoint):

export ANTHROPIC_BASE_URL="http://127.0.0.1:4000"
export ANTHROPIC_AUTH_TOKEN="your-litellm-key"
claude

Codex CLI (config.toml, OpenAI-format):

model = "deepseek-chat"
model_provider = "litellm"

[model_providers.litellm]
name = "LiteLLM"
base_url = "http://127.0.0.1:4000/v1"
env_key = "LITELLM_KEY"
wire_api = "chat"

OpenCode (opencode.json, OpenAI-format):

{
  "provider": {
    "litellm": {
      "npm": "@ai-sdk/openai-compatible",
      "options": { "baseURL": "http://127.0.0.1:4000/v1", "apiKey": "{env:LITELLM_KEY}" },
      "models": { "deepseek-chat": { "name": "DeepSeek via LiteLLM" } }
    }
  }
}

All three now share one provider config and one spend view.

Track and cap spend

A real benefit of the gateway is visibility: LiteLLM can record usage per model and tool and enforce budgets. If you’re running cheap models across several agents, that’s the simplest way to see total spend and stop surprises.

Troubleshooting

  • Tool can’t connect — gateway not running, or wrong port/base URL.
  • Auth errors — the LiteLLM key the tool sends doesn’t match the gateway’s.
  • Model not found — the model name isn’t mapped in the LiteLLM config.
  • Codex format errors — set wire_api = "chat" for the LiteLLM provider.

LiteLLM gateway checklist

  • Gateway running via Python or Docker (WSL/Docker Desktop)
  • Providers and model names mapped in the config
  • Keys via environment variables; master key set
  • Claude Code on the Anthropic endpoint; Codex/OpenCode on /v1
  • Spend tracking reviewed; gateway bound to localhost

Wrapping up

LiteLLM is the right tool when you run multiple coding agents: one gateway fronts all your cheap providers, serves both Anthropic and OpenAI formats, and tracks spend, so Claude Code, Codex, and OpenCode share a single config. Run it via Docker or Python on Windows, map your models, point each tool at the local endpoint, and secure it with a master key on localhost.

For lighter, single-tool routing, see Claude Code Router or claude-code-mux.

Frequently asked questions

What is a LiteLLM gateway?

LiteLLM is an open-source proxy/gateway that exposes 100+ model providers behind a single OpenAI-compatible (and Anthropic-compatible) endpoint. You run it once, point all your tools at it, and manage keys, model mappings, and spend in one place.

Why use it for coding CLIs?

Instead of configuring DeepSeek, Qwen, GLM, and Kimi separately in Claude Code, Codex, and OpenCode, you configure them once in LiteLLM and point every tool at the gateway. It also tracks spend and can enforce budgets across tools.

Can it serve both OpenAI-format and Anthropic-format tools?

Yes. LiteLLM can present an OpenAI-compatible endpoint for Codex and OpenCode and an Anthropic-compatible one for Claude Code, mapping both to the same underlying providers. That's its main advantage for a mixed toolset.

Does it run on Windows?

Yes — via Python or Docker. WSL or Docker Desktop is the smoothest way on Windows to run the gateway as a persistent local service.

Is it free?

LiteLLM is open source and free to self-host; you pay only for the providers behind it. There's also a hosted/enterprise offering, but the self-hosted gateway covers individual use.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.