← Back to feed
Project Tool

LiteLLM Proxy

Unified proxy routing Claude Code between claude.ai and DeepSeek via LiteLLM.

LiteLLM Proxy

A small local proxy that lets Claude Code talk to either the claude.ai subscription or a DeepSeek API key, without touching how the CLI or the VS Code extension actually work.

It's the piece underneath Relay — a menu-bar toggle for switching providers on the fly. LiteLLM runs in its own isolated Python venv and exposes an Anthropic-compatible /v1/messages endpoint (plus /v1/messages/count_tokens, which the VS Code extension calls separately and needs serving too), so from Claude Code's point of view nothing about the wire protocol changes — only the base URL and auth token do.

Relay menu-bar toggle switching Claude Code between providers
The Relay menu-bar toggle that drives the proxy.
Wildcard routingModel IDs pass through as-is (claude-sonnet-5, claude-opus-4-8) via a catch-all mapping, so it never needs an alias name configured on the client side.
Vision fallbackAn optional pre-call hook detects image content in requests and routes it through Groq's vision model first, so a text-only backend can still "see" screenshots.
Two separate writesThe CLI reads env.ANTHROPIC_BASE_URL from ~/.claude/settings.json (strict JSON, full merge); VS Code reads claudeCode.environmentVariables from its own settings, which is hand-edited JSONC — patched textually instead of reparsed so comments survive.
Health-checked startupThe proxy isn't reported "Running" until its /health/liveliness endpoint responds; on relaunch, a pidfile + proc_pidpath + health check together decide whether to adopt an already-running proxy or start fresh.
Relay / LiteLLM proxy architecture — Claude Code CLI and VS Code extension routed through the local proxy to claude.ai or DeepSeek
How the proxy sits between Claude Code and the two providers.

The DeepSeek API key lives in the login Keychain, never on disk, and the LiteLLM master key is generated fresh on first launch with SecRandomCopyBytes. Revert is instant: unset the env vars and the CLI falls straight back to the claude.ai subscription, no re-auth needed. Built as the backend for a personal tool, not a hosted service.

Python · LiteLLM