Overview
OpenCode is a terminal-based AI coding assistant. By connecting it to Eden AI, you get:- 500+ models: Access OpenAI, Anthropic, Google, and more through a single API key
- Auto-configured: A script fetches Eden AI’s full model catalog and writes your config automatically
- Tool calling: Only models that support function calling are written to the config, which is what OpenCode requires
Prerequisites
- Node.js and npm installed
- Python 3.9+ with
requests(pip install requests) to run the config generator - Eden AI API key from app.edenai.run → API Keys
Setup
1. Install OpenCode
2. Generate your config
Save the script below asgen_opencode_config.py and run it:
edenai provider to ~/.config/opencode/opencode.json (on Windows: %USERPROFILE%\.config\opencode\opencode.json). Existing settings in that file are preserved — only the edenai provider entry is replaced.
limit (context window, so the TUI can track context usage and trigger compaction), cost per million tokens, tool_call, reasoning, and the input/output modalities that gate file and image attachments.
3. Connect your API key
Launch OpenCode, run/connect, select Eden AI from the list, and paste your API key when prompted. The credential is stored in OpenCode’s auth file, outside of opencode.json.
4. Pick a model and start coding
/models and pick any Eden AI model. To set a default instead, add a top-level model key to ~/.config/opencode/opencode.json using edenai/ plus the Eden AI model ID:
Eden AI model IDs already contain a slash (
anthropic/claude-sonnet-latest), and some contain several (together_ai/meta-models/Muse-Glimmer-30B). OpenCode splits only on the first slash, so edenai/<full-eden-model-id> is the correct form.Switching models
Re-run the script whenever you want to refresh the catalog — new models appear in/models the next time OpenCode starts. Browse the full list via List Models or GET https://api.edenai.run/v3/models.
Troubleshooting
401 Unauthorized
The credential is missing or wrong. Re-run /connect and paste a fresh key from app.edenai.run → API Keys, watching for leading or trailing spaces.
Eden AI does not appear in /connect or /models
OpenCode did not load the provider. Confirm the config parses and contains the provider:
UnknownError right after sending a message
Usually a mistyped model reference — OpenCode reports an unknown model as a generic server error rather than a “model not found” message. Use edenai/ followed by the complete Eden AI model ID (edenai/anthropic/claude-sonnet-latest, not edenai/claude-sonnet-latest); it must match a key under provider.edenai.models in your config. Run opencode models to see the exact strings OpenCode loaded.
Connection issues
ConfirmbaseURL is exactly https://api.edenai.run/v3 — the OpenAI-compatible client appends /chat/completions itself. Check Eden AI status at app-edenai.instatus.com.
Next Steps
- Codex CLI - OpenAI’s open-source local coding agent
- Continue.dev - AI code assistant for VS Code and JetBrains
- Claude Code - Official Claude CLI