pip install 'litellm[proxy]'Create a .env file in your home directory or export it:
export ANTHROPIC_API_KEY="your-api-key-here"In a separate terminal, run:
litellm --model claude-sonnet-4-20250514 --api_key $ANTHROPIC_API_KEYOr with a config file (litellm_config.yaml):
model_list:
- model_name: claude-sonnet-4-20250514
litellm_params:
model: anthropic/claude-sonnet-4-20250514
api_key: os.environ/ANTHROPIC_API_KEYThen:
litellm --config litellm_config.yamlThe proxy should start on http://localhost:4000 by default.
Edit .env.local in this directory:
LITELLM_API_URL=http://localhost:4000/v1/chat/completions
LITELLM_API_KEY=sk-1234 # Can be any string if your proxy doesn't require auth
npm run devOpen http://localhost:3000 in your browser.
Make sure you see output like:
INFO: Uvicorn running on http://0.0.0.0:4000 (Press CTRL+C to quit)
- Check that LiteLLM is running on port 4000
- Verify your ANTHROPIC_API_KEY is set correctly
- Check the browser console and terminal for error messages
- Try testing the LiteLLM endpoint directly:
curl http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-1234" \
-d '{
"model": "claude-sonnet-4-20250514",
"messages": [{"role": "user", "content": "Say hello"}]
}'If port 3000 or 4000 is in use:
For the app:
PORT=3001 npm run devFor LiteLLM:
litellm --port 4001 --model claude-sonnet-4-20250514Then update .env.local accordingly.
If you don't want to use LiteLLM, you can modify app/api/claude/route.ts to call the Anthropic API directly. The code currently converts between OpenAI and Anthropic formats to support LiteLLM.