From 3a0ea80c757f47309c221222261c57b60e941a44 Mon Sep 17 00:00:00 2001
From: Cole McIntosh <82463175+colesmcintosh@users.noreply.github.com>
Date: Thu, 17 Jul 2025 00:07:29 -0600
Subject: [PATCH] Add Claude Code LiteLLM tutorial (#12650)
* Add concise Claude Code + LiteLLM Gateway tutorial
- Create focused tutorial matching existing tutorial style
- Step-by-step guide from installation to advanced configurations
- Multi-provider configuration examples (AWS Bedrock, Azure OpenAI, Load Balancing)
- Based on Anthropic's official LiteLLM configuration documentation
- Added to sidebar with clean title 'Use LiteLLM with Claude Code'
- Fixed sidebar reference from 'secret' to 'set_keys' for proper document resolution
* Update config_settings.md to correct documentation links for key management and Hashicorp Vault settings. Changed references from 'secret.md' to 'set_keys.md' for improved clarity and accuracy.
* Update sidebar and config_settings.md to reflect changes in key management documentation. Changed sidebar reference from 'set_keys' to 'secret' and updated links in config_settings.md for Hashicorp Vault settings to point to 'secret.md' for improved accuracy.
* Remove extra tutorial and update sidebar accordingly
* Update tutorial title from 'WebUI' to 'Open WebUI' for clarity and consistency in documentation.
* Remove Python version requirement from Claude Responses API tutorial for clarity and to align with updated prerequisites.
---
.../docs/tutorials/claude_responses_api.md | 141 ++++++++++++++++--
.../tutorials/github_copilot_integration.md | 4 +-
.../docs/tutorials/litellm_gemini_cli.md | 2 +-
.../my-website/docs/tutorials/openai_codex.md | 2 +-
docs/my-website/docs/tutorials/openweb_ui.md | 2 +-
docs/my-website/sidebars.js | 2 +-
6 files changed, 132 insertions(+), 21 deletions(-)
diff --git a/docs/my-website/docs/tutorials/claude_responses_api.md b/docs/my-website/docs/tutorials/claude_responses_api.md
index 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 Code
This 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:
+
```yaml
model_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:
```bash
curl -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:
```bash
export 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 alias
claude --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:
+
+
+
+
+```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
+```
+
+
+
\ No newline at end of file
diff --git a/docs/my-website/docs/tutorials/github_copilot_integration.md b/docs/my-website/docs/tutorials/github_copilot_integration.md
index 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 Copilot
This 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.md
index 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 CLI
This 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.md
index 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 Codex
This guide walks you through connecting OpenAI Codex to LiteLLM. Using LiteLLM with Codex allows teams to:
- Access 100+ LLMs through the Codex interface
diff --git a/docs/my-website/docs/tutorials/openweb_ui.md b/docs/my-website/docs/tutorials/openweb_ui.md
index 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 WebUI
This guide walks you through connecting Open WebUI to LiteLLM. Using LiteLLM with Open WebUI allows teams to
- Access 100+ LLMs on Open WebUI
diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js
index 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"
]
},