Documentation: - OpenCode + LiteLLM integration guide - LiteLLM complete setup with 16 models - Gitea centralized configuration guide - Testing procedures and verification - API keys setup instructions Configurations: - OpenCode config pointing to LiteLLM - Updated LiteLLM config with all models - Nextcloud docker-compose template Scripts: - Gitea setup automation - OpenCode testing script Infrastructure: - Gitea: 192.168.88.200:3000 - LiteLLM: 192.168.88.27:4000 - Nextcloud: 192.168.88.62
6.3 KiB
LiteLLM API Keys Setup - Claude & Gemini Pro Added
✅ What's Been Updated
Your LiteLLM gateway now supports 3 major AI platforms:
OpenAI (3 models)
gpt-4- Most capablegpt-4-turbo- Fastergpt-3.5-turbo- Budget-friendly
Anthropic Claude (4 models)
claude-3-opus- Most capable Claudeclaude-3-sonnet- Best balanceclaude-3-haiku- Lightweightclaude-2.1- Previous generation
Google Gemini (3 models)
gemini-pro- Main modelgemini-pro-vision- With visiongemini-1.5-pro- Latest
🔑 Getting Your API Keys
1. OpenAI API Key
1. Go to: https://platform.openai.com/api-keys
2. Click "Create new secret key"
3. Copy the key (starts with sk-...)
2. Claude (Anthropic) API Key
1. Go to: https://console.anthropic.com/
2. Navigate to "API Keys"
3. Create new key
4. Copy it (starts with sk-ant-...)
3. Gemini (Google) API Key
1. Go to: https://ai.google.dev/
2. Click "Get API Key"
3. Create new key in Google Cloud
4. Copy it
📝 Add Keys to Your Gateway
SSH into docker-server and edit the .env file:
ssh jgitta@192.168.88.27
cd /opt/litellm
nano .env
Replace the placeholders with your actual keys:
# OpenAI API Keys
OPENAI_API_KEY=sk-your-actual-openai-key-here
# Anthropic Claude API Key
ANTHROPIC_API_KEY=sk-ant-your-actual-claude-key-here
# Google Gemini API Key
GOOGLE_API_KEY=your-actual-google-gemini-api-key-here
# Master authentication key (change this in production)
LITELLM_MASTER_KEY=litellm-local-key-change-in-production
To save and exit nano:
Ctrl+X → Y → Enter
🚀 Restart LiteLLM with New Keys
After updating .env:
cd /opt/litellm
docker-compose down
docker-compose up -d
sleep 10
docker logs litellm | tail -20
If you see models loading without errors, you're good!
✅ Test Each Provider
Test OpenAI (GPT-4)
curl -X POST http://192.168.88.27:4000/chat/completions \
-H "Authorization: Bearer litellm-local-key-change-in-production" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Say hello OpenAI!"}]
}' | jq '.choices[0].message'
Test Claude (Anthropic)
curl -X POST http://192.168.88.27:4000/chat/completions \
-H "Authorization: Bearer litellm-local-key-change-in-production" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-opus",
"messages": [{"role": "user", "content": "Say hello Claude!"}]
}' | jq '.choices[0].message'
Test Gemini (Google)
curl -X POST http://192.168.88.27:4000/chat/completions \
-H "Authorization: Bearer litellm-local-key-change-in-production" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-pro",
"messages": [{"role": "user", "content": "Say hello Gemini!"}]
}' | jq '.choices[0].message'
💻 Use from Your VMs
Now any VM (jellyfin, next, photos, haos, etc.) can use any model:
Python Example - Switch Between Models
import requests
import json
ENDPOINT = "http://192.168.88.27:4000/chat/completions"
AUTH = "Bearer litellm-local-key-change-in-production"
def ask_model(model, question):
response = requests.post(
ENDPOINT,
headers={"Authorization": AUTH, "Content-Type": "application/json"},
json={
"model": model,
"messages": [{"role": "user", "content": question}]
}
)
return response.json()['choices'][0]['message']['content']
# Use any model:
print("GPT-4:", ask_model("gpt-4", "What is AI?"))
print("Claude:", ask_model("claude-3-opus", "What is AI?"))
print("Gemini:", ask_model("gemini-pro", "What is AI?"))
Bash Example - List All Available Models
curl http://192.168.88.27:4000/models \
-H "Authorization: Bearer litellm-local-key-change-in-production" | jq '.data[].id'
📋 Configuration Files Updated
All files are in /opt/litellm/ on docker-server:
| File | Purpose |
|---|---|
.env |
Your API keys (never commit to git) |
config/litellm_config.yaml |
Model definitions |
config/README.md |
Usage documentation |
docker-compose.yml |
Docker service config |
🔒 Security Reminders
⚠️ IMPORTANT:
- ✅ API keys are in
.env(not in git) - Good practice! - ✅ Each provider's key is separate - Can rotate independently
- ✅ Master key is configurable - Change from default in production
- 🔄 Git is initialized - Ready for version control when needed
Never Do This:
# ❌ DON'T commit .env to git
git add .env
git commit -m "my keys"
# ❌ DON'T put API keys in litellm_config.yaml
# Use ${ENVIRONMENT_VAR} references instead
# ❌ DON'T expose port 4000 to the internet without HTTPS
# Use Caddy (already on your network) as reverse proxy
🎯 What's Ready
✅ LiteLLM Gateway: Running on docker-server (192.168.88.27:4000) ✅ Configuration: All 3 providers configured ✅ API Key Placeholders: Ready for your actual keys ✅ Documentation: Complete usage examples ✅ Git: Initialized and ready for tracking changes ✅ Docker: Compose file handles everything
📞 Troubleshooting
"Model not available"
# Check what models are actually loaded:
curl http://192.168.88.27:4000/models \
-H "Authorization: Bearer litellm-local-key-change-in-production" | jq
"Invalid API key"
- Verify key format matches provider (sk-* for OpenAI, sk-ant-* for Claude, etc.)
- Check
.envfile saved correctly - Restart:
docker-compose down && docker-compose up -d
"Connection refused"
- Ensure container is running:
docker ps | grep litellm - Check logs:
docker logs litellm - Verify port 4000 is accessible:
curl http://localhost:4000/models
📚 Quick Links
- OpenAI API: https://platform.openai.com/api-keys
- Anthropic Console: https://console.anthropic.com/
- Google AI Studio: https://ai.google.dev/
- LiteLLM Docs: https://docs.litellm.ai/
- Your Complete Guide: See
litellm-complete-setup.md
✨ Next Steps
- Get API keys from the three providers
- Add keys to
.envon docker-server - Restart LiteLLM
- Test each model with the curl examples above
- Update your VMs to use the gateway endpoint
That's it! All three providers are now available through a single unified endpoint. 🚀