mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
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.
This commit is contained in:
parent
4b09d0d517
commit
3a0ea80c75
6 changed files with 132 additions and 21 deletions
|
|
@ -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:
|
||||
|
||||
<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' }} />
|
||||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ const sidebars = {
|
|||
type: "category",
|
||||
label: "Secret Managers",
|
||||
items: [
|
||||
"set_keys",
|
||||
"secret",
|
||||
"oidc"
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue