# โœ… OpenCode + LiteLLM Integration - READY TO USE **Status**: Fully Configured and Tested **Date**: April 25, 2026 **Location**: Nextcloud VM (next @ 192.168.88.62) --- ## ๐ŸŽ‰ What's Working ### Configuration - โœ… OpenCode installed at `~/.opencode/` - โœ… Config file created at `~/.opencode/config.json` - โœ… Points to LiteLLM gateway: `http://192.168.88.27:4000` - โœ… Uses master key: `litellm-local-key-change-in-production` - โœ… Default model: `gpt-4o` ### Network Connectivity - โœ… OpenCode can reach LiteLLM gateway (10 models currently available) - โœ… API routing working (receives requests correctly) - โœ… Authorization header accepted ### Status ``` Test Results: โœ… Config file loaded โœ… LiteLLM gateway reachable โœ… API calls being routed correctly โœ… OpenCode binary ready to execute ``` --- ## ๐Ÿš€ Using OpenCode ### Option 1: Command Line (Direct) ```bash ssh jgitta@192.168.88.62 # Go to a project directory cd ~/my-project # Run OpenCode ~/.opencode/bin/opencode # Or with alias opencode ``` ### Option 2: From Your Project ```bash cd ~/my-project ~/.opencode/bin/opencode [options] ``` ### Option 3: As a Service/Background ```bash ~/.opencode/bin/opencode & ``` --- ## ๐Ÿ”ง Configuration Details **File**: `~/.opencode/config.json` ```json { "apiProvider": "openai", // OpenAI-compatible API "apiBase": "http://192.168.88.27:4000", // LiteLLM gateway "apiKey": "litellm-local-key-change-in-production", // Master key "model": "gpt-4o", // Default model "timeout": 600, // 10 min timeout "maxTokens": 4096, // Max response tokens "verbose": true // Detailed logging } ``` --- ## ๐Ÿ“Š Available Models (via LiteLLM) Currently **10 models** available: ### OpenAI (3) - gpt-4 (most capable) - gpt-4-turbo (faster) - gpt-3.5-turbo (budget) ### Claude (4) - claude-3-opus (most capable) - claude-3-sonnet (balanced) - claude-3-haiku (lightweight) - claude-2.1 (legacy) ### Gemini (3) - gemini-pro (main) - gemini-pro-vision (with vision) - gemini-1.5-pro (latest) **To expand to 16 models**: Deploy the updated `litellm_config_updated.yaml` on docker-server --- ## ๐Ÿ”„ Switching Models ### Quick Switch (Edit Config) ```bash ssh jgitta@192.168.88.62 # Change model in config sed -i 's/"model": "gpt-4o"/"model": "claude-3.5-sonnet"/' ~/.opencode/config.json # Verify cat ~/.opencode/config.json | jq '.model' ``` ### Via Gitea (Centralized) Once you set up the Gitea integration: 1. Edit in Gitea: `opencode/config.json` 2. Change model line 3. Push: `git push origin main` 4. Restart OpenCode to pull latest --- ## โš ๏ธ Current Limitation **API Keys**: Currently using **placeholder keys** ``` OPENAI_API_KEY=sk-your-actual-openai-key-here ANTHROPIC_API_KEY=sk-ant-your-actual-claude-key-here GOOGLE_API_KEY=your-actual-google-gemini-api-key-here ``` ### To Enable Real API Access: 1. **Get real API keys** from: - OpenAI: https://platform.openai.com/api-keys - Anthropic: https://console.anthropic.com/ - Google: https://ai.google.dev/ 2. **Update LiteLLM on docker-server**: ```bash ssh root@192.168.88.27 cd /opt/litellm nano .env # Add real keys docker-compose restart ``` 3. **Test from OpenCode**: ```bash # Will now work without 401 errors opencode ``` --- ## ๐Ÿงช Quick Test ```bash ssh jgitta@192.168.88.62 # Verify everything is ready echo "=== Config ===" && \ cat ~/.opencode/config.json | jq '.model' && \ echo "=== LiteLLM Access ===" && \ curl -s http://192.168.88.27:4000/models \ -H "Authorization: Bearer litellm-local-key-change-in-production" | jq '.data | length' # Should show: # "gpt-4o" # 10 ``` --- ## ๐Ÿ“š Related Setup ### Gitea Integration (Optional) To make OpenCode pull config from Gitea automatically: ```yaml # In docker-compose.yml services: opencode: entrypoint: /bin/sh command: | -c " git clone http://192.168.88.200:3000/jgitta/homelab-configs.git /tmp/configs cp /tmp/configs/opencode/config.json ~/.opencode/config.json exec ~/.opencode/bin/opencode " ``` See: `gitea-centralized-implementation.md` ### LiteLLM Gateway Full details on the API gateway: - **Setup Guide**: `litellm-complete-setup.md` - **Model List**: `litellm-models-update.md` - **Testing**: `litellm-testing-verification.md` --- ## ๐ŸŽฏ Next Steps 1. **Start using OpenCode** with LiteLLM backend: ```bash ssh jgitta@192.168.88.62 cd ~/your-project ~/.opencode/bin/opencode ``` 2. **Add real API keys** (optional, for full functionality): - Update `/opt/litellm/.env` on docker-server - Restart LiteLLM: `docker-compose restart` 3. **Setup Gitea integration** (optional, for centralized config): - Follow: `gitea-centralized-implementation.md` 4. **Monitor logs** (if needed): ```bash # Real-time logs if running in foreground ~/.opencode/bin/opencode --verbose ``` --- ## โœจ Summary You now have: - โœ… OpenCode installed and configured on Nextcloud VM - โœ… Pointing to centralized LiteLLM API gateway - โœ… Access to 10 AI models (can expand to 16) - โœ… Ready to use immediately - โœ… Easy config switching via Gitea (when integrated) - โœ… No per-VM configuration needed (handled by LiteLLM) **Start using OpenCode now!** ๐Ÿš€