A LiteLLM proxy that routes any model request to your Azure AI Foundry deployment. Useful for running Claude Code against an AI model hosted on Azure Foundry.
- uv installed
- An Azure AI Foundry deployment with an API key
cp .env.example .envEdit .env and fill in your values:
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_API_KEY=
AZURE_OPENAI_DEPLOYMENT=azure/responses/gpt-5.3-codex
AZURE_OPENAI_API_VERSION=preview
LITELLM_PORT=4000
LITELLM_MASTER_KEY=sk-foo-bar-baz
LITELLM_LOCAL_MODEL_COST_MAP=true
UI_USERNAME=litellm
UI_PASSWORD=litellm
POSTGRES_USER=litellm
POSTGRES_PASSWORD=litellm
POSTGRES_DB=litellm| Variable | Description |
|---|---|
AZURE_OPENAI_ENDPOINT |
Your Azure AI Foundry endpoint URL |
AZURE_OPENAI_API_KEY |
API key for the endpoint |
AZURE_OPENAI_DEPLOYMENT |
Model deployment name with provider prefix (e.g. azure/responses/gpt-5.3-codex) |
AZURE_OPENAI_API_VERSION |
Azure API version (preview for Codex models, or a dated version like 2025-03-01-preview) |
LITELLM_PORT |
Port for the proxy (default: 4000) |
LITELLM_MASTER_KEY |
Auth token for the proxy — used by clients to authenticate against the LiteLLM proxy |
LITELLM_LOCAL_MODEL_COST_MAP |
Set to true to skip fetching the remote cost map (avoids SSL errors behind corporate proxies) |
UI_USERNAME |
Username for the LiteLLM admin UI at /ui (default: litellm) |
UI_PASSWORD |
Password for the LiteLLM admin UI at /ui (default: litellm) |
POSTGRES_USER |
PostgreSQL username (default: litellm, used by Docker Compose) |
POSTGRES_PASSWORD |
PostgreSQL password (default: litellm, used by Docker Compose) |
POSTGRES_DB |
PostgreSQL database name (default: litellm, used by Docker Compose) |
Security note: The default values for
LITELLM_MASTER_KEY,UI_PASSWORD,POSTGRES_USER, andPOSTGRES_PASSWORDare not secure. If you expose this proxy beyond localhost (e.g. on a shared network or in production), replace them with strong, unique values.
./start_proxy.shThe proxy starts on port 4000 by default. Override with LITELLM_PORT in your .env.
In a separate terminal:
export ANTHROPIC_BASE_URL=http://localhost:4000
export ANTHROPIC_AUTH_TOKEN=<your-LITELLM_MASTER_KEY>
claudeClaude Code needs two environment variables to connect through the proxy. You can set them in different ways depending on your workflow.
See also the official LiteLLM guide: Use Claude Code with Non-Anthropic Models.
Set them in your shell before launching Claude Code:
export ANTHROPIC_BASE_URL=http://localhost:4000
export ANTHROPIC_AUTH_TOKEN=<your-LITELLM_MASTER_KEY>
claudeRun claude config or edit ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:4000",
"ANTHROPIC_AUTH_TOKEN": "<your-LITELLM_MASTER_KEY>"
}
}This persists across sessions so you don't need to export variables each time.
Add to your VS Code settings.json:
{
"claude-code.env": {
"ANTHROPIC_BASE_URL": "http://localhost:4000",
"ANTHROPIC_AUTH_TOKEN": "<your-LITELLM_MASTER_KEY>"
}
}By default Claude Code picks a model name like claude-sonnet-4-20250514. Since the proxy uses a wildcard, any model name is accepted and routed to your Azure deployment. You can also specify a model explicitly:
claude --model gpt-5.3-codexcurl -X POST http://localhost:4000/v1/messages \
-H "Authorization: Bearer <your-LITELLM_MASTER_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 100,
"messages": [{"role": "user", "content": "Hello!"}]
}'The litellm_config.yaml uses a wildcard (model_name: "*") so any model name sent by the client is routed to your single Azure deployment. The start_proxy.sh script uses uv run with UV_NATIVE_TLS=true to use the system certificate store, avoiding SSL issues behind corporate proxies.
The Dockerfile uses the official LiteLLM Docker image — no need to install uv or Python separately.
docker build -t litellm-claude-code-proxy .docker run --env-file .env -p 4000:4000 litellm-claude-code-proxyOr skip the build entirely and run the official image directly:
docker run \
--env-file .env \
-v $(pwd)/litellm_config.yaml:/app/config.yaml \
-p 4000:4000 \
docker.litellm.ai/berriai/litellm:main-stable \
--config /app/config.yaml --port 4000The container reads all configuration from environment variables via the .env file.
Docker Compose sets up both the LiteLLM proxy and a PostgreSQL database, which enables virtual keys, spend tracking, and other DB-backed features.
Make sure your .env includes the database variables (see .env.example):
POSTGRES_USER=litellm
POSTGRES_PASSWORD=litellm
POSTGRES_DB=litellmThe DATABASE_URL is assembled automatically from these variables in docker-compose.yml — you don't need to set it yourself.
docker compose up --buildThis starts:
- litellm — the proxy on port
4000(override withLITELLM_PORT) - db — PostgreSQL 16 with a persistent
pgdatavolume
The proxy waits for Postgres to be healthy before starting.
docker compose down # stop containers (data is preserved in the volume)
docker compose down -v # stop containers and delete the database volume