The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add Claude Code LiteLLM tutorial (#12650)
Cole McIntosh3a0ea80c757f
diff --git a/docs/my-website/docs/tutorials/claude_responses_api.md b/docs/my-website/docs/tutorials/claude_responses_api.mdindex 668398537ba..171e86fff51 100644--- a/docs/my-website/docs/tutorials/claude_responses_api.md+++ b/docs/my-website/docs/tutorials/claude_responses_api.md@@ -1,25 +1,58 @@import Image from '@theme/IdealImage';+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';-# Call Responses API models on Claude Code+# Claude CodeThis tutorial shows how to call the Responses API models like `codex-mini` and `o3-pro` from the Claude Code endpoint on LiteLLM.+:::info-Pre-requisites:+This tutorial is based on [Anthropic's official LiteLLM configuration documentation](https://docs.anthropic.com/en/docs/claude-code/llm-gateway#litellm-configuration). This integration allows you to use any LiteLLM supported model through Claude Code.++:::++## Prerequisites- [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) installed-- LiteLLM v1.72.6-stable or higher+- API keys for your chosen providers++## Installation++First, install LiteLLM with proxy support:+```bash+pip install 'litellm[proxy]'+```### 1. Setup config.yaml+Create a secure configuration using environment variables:+```yamlmodel_list:- - model_name: codex-mini- litellm_params:- model: openai/codex-mini- api_key: sk-proj-1234567890- api_base: https://api.openai.com/v1+ # Responses API models+ - model_name: codex-mini+ litellm_params:+ model: openai/codex-mini+ api_key: os.environ/OPENAI_API_KEY+ api_base: https://api.openai.com/v1++ - model_name: o3-pro+ litellm_params:+ model: openai/o3-pro+ api_key: os.environ/OPENAI_API_KEY+ api_base: https://api.openai.com/v1++litellm_settings:+ master_key: os.environ/LITELLM_MASTER_KEY+```++Set your environment variables:++```bash+export OPENAI_API_KEY="your-openai-api-key"+export LITELLM_MASTER_KEY="sk-1234567890" # Generate a secure key```### 2. Start proxy@@ -30,11 +63,13 @@ litellm --config /path/to/config.yaml# RUNNING on http://0.0.0.0:4000```-### 3. Test it! (Curl)+### 3. Verify Setup++Test that your proxy is working correctly:```bashcurl -X POST http://0.0.0.0:4000/v1/messages \--H "Authorization: Bearer sk-proj-1234567890" \+-H "Authorization: Bearer $LITELLM_MASTER_KEY" \-H "Content-Type: application/json" \-d '{"model": "codex-mini",@@ -42,21 +77,97 @@ curl -X POST http://0.0.0.0:4000/v1/messages \}'```-### 4. Test it! (Claude Code)+### 4. Configure Claude Code-- Setup environment variables+Setup Claude Code to use your LiteLLM proxy:```bashexport ANTHROPIC_BASE_URL="http://0.0.0.0:4000"-export ANTHROPIC_API_KEY="sk-1234" # replace with your LiteLLM key+export ANTHROPIC_API_KEY="$LITELLM_MASTER_KEY"```-- Start a Claude Code session+### 5. Use Claude Code++Start Claude Code with any configured model:```bash+# Use Responses API models+claude --model codex-mini+claude --model o3-pro++# Or use the latest model aliasclaude --model codex-mini-latest```-- Send a message+Example conversation:++## Troubleshooting++Common issues and solutions:++**Claude Code not connecting:**+- Verify your proxy is running: `curl http://0.0.0.0:4000/health`+- Check that `ANTHROPIC_BASE_URL` is set correctly+- Ensure your `ANTHROPIC_API_KEY` matches your LiteLLM master key++**Authentication errors:**+- Verify your environment variables are set: `echo $LITELLM_MASTER_KEY`+- Check that your OpenAI API key is valid and has sufficient credits++**Model not found:**+- Ensure the model name in Claude Code matches exactly with your `config.yaml`+- Check LiteLLM logs for detailed error messages++## Using Multiple Models++Expand your configuration to support multiple providers and models:++<Tabs>+<TabItem value="responses-plus" label="Responses + Standard Models">++```yaml+model_list:+ # Responses API models+ - model_name: codex-mini+ litellm_params:+ model: openai/codex-mini+ api_key: os.environ/OPENAI_API_KEY+ api_base: https://api.openai.com/v1++ - model_name: o3-pro+ litellm_params:+ model: openai/o3-pro+ api_key: os.environ/OPENAI_API_KEY+ api_base: https://api.openai.com/v1++ # Standard models+ - model_name: gpt-4o+ litellm_params:+ model: openai/gpt-4o+ api_key: os.environ/OPENAI_API_KEY++ - model_name: claude-3-5-sonnet+ litellm_params:+ model: anthropic/claude-3-5-sonnet-20241022+ api_key: os.environ/ANTHROPIC_API_KEY++litellm_settings:+ master_key: os.environ/LITELLM_MASTER_KEY+```++Switch between models seamlessly:++```bash+# Use Responses API models for advanced reasoning+claude --model o3-pro+claude --model codex-mini++# Use standard models for general tasks+claude --model gpt-4o+claude --model claude-3-5-sonnet+```++</TabItem>+</Tabs><Image img={require('../../img/release_notes/claude_code_demo.png')} style={{ width: '500px', height: 'auto' }} />\ No newline at end of filediff --git a/docs/my-website/docs/tutorials/github_copilot_integration.md b/docs/my-website/docs/tutorials/github_copilot_integration.mdindex 97c01e5ccf6..fc2682df6f9 100644--- a/docs/my-website/docs/tutorials/github_copilot_integration.md+++ b/docs/my-website/docs/tutorials/github_copilot_integration.md@@ -1,11 +1,11 @@----sidebar_label: "Use LiteLLM with GitHub Copilot"+sidebar_label: "GitHub Copilot"---import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';-# Use LiteLLM with GitHub Copilot+# GitHub CopilotThis tutorial shows you how to integrate GitHub Copilot with LiteLLM Proxy, allowing you to route requests through LiteLLM's unified interface.diff --git a/docs/my-website/docs/tutorials/litellm_gemini_cli.md b/docs/my-website/docs/tutorials/litellm_gemini_cli.mdindex bf8e2cb44cb..a36d898d7da 100644--- a/docs/my-website/docs/tutorials/litellm_gemini_cli.md+++ b/docs/my-website/docs/tutorials/litellm_gemini_cli.md@@ -1,4 +1,4 @@-# Use LiteLLM with Gemini CLI+# Gemini CLIThis tutorial shows you how to integrate the Gemini CLI with LiteLLM Proxy, allowing you to route requests through LiteLLM's unified interface.diff --git a/docs/my-website/docs/tutorials/openai_codex.md b/docs/my-website/docs/tutorials/openai_codex.mdindex bb5af956b0c..41416f85159 100644--- a/docs/my-website/docs/tutorials/openai_codex.md+++ b/docs/my-website/docs/tutorials/openai_codex.md@@ -2,7 +2,7 @@ import Image from '@theme/IdealImage';import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';-# Using LiteLLM with OpenAI Codex+# OpenAI CodexThis guide walks you through connecting OpenAI Codex to LiteLLM. Using LiteLLM with Codex allows teams to:- Access 100+ LLMs through the Codex interfacediff --git a/docs/my-website/docs/tutorials/openweb_ui.md b/docs/my-website/docs/tutorials/openweb_ui.mdindex a55a913bbe1..fa8e3cdad29 100644--- a/docs/my-website/docs/tutorials/openweb_ui.md+++ b/docs/my-website/docs/tutorials/openweb_ui.md@@ -2,7 +2,7 @@ import Image from '@theme/IdealImage';import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';-# Open WebUI with LiteLLM+# Open WebUIThis guide walks you through connecting Open WebUI to LiteLLM. Using LiteLLM with Open WebUI allows teams to- Access 100+ LLMs on Open WebUIdiff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.jsindex 7b7e712d910..85a000f760f 100644--- a/docs/my-website/sidebars.js+++ b/docs/my-website/sidebars.js@@ -213,7 +213,7 @@ const sidebars = {type: "category",label: "Secret Managers",items: [- "set_keys",+ "secret","oidc"]},