opencode.json that lists every Eden AI model with function calling, connects your key, and covers both lines.
Overview
OpenCode is a terminal-based AI coding assistant. By connecting it to Eden AI, you get:- 1000+ 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, only if you install with npm
- 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
All three commands install OpenCode 1, which is what the rest of this page covers.
brew install opencode, without the anomalyco/tap/ prefix, installs OpenCode 2. OpenCode 2 is also published as @opencode/cli and uses a different config key. See OpenCode 2 below.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, and 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 name:
Model naming
Use a model name or~ alias from GET /v3/models, such as ~claude-sonnet-latest; a provider/model id pins one provider. The generated config lists models by name, without a provider. Eden AI routes each call to a provider that serves the model, so the config keeps only models with function calling on every provider. OpenCode splits a model reference on the first slash only, so a reference is edenai/ plus the name: edenai/~claude-sonnet-latest.
A pinned reference such as edenai/anthropic/claude-sonnet-latest works too, once you add its provider/model ID as a key under provider.edenai.models, since OpenCode only uses models listed there.
Switching models
Run/models and pick another model, or change the top-level model key as shown in step 4. Re-run the script whenever you want to refresh the catalog: new models appear in /models the next time OpenCode starts.
OpenCode 2
OpenCode 2 is a separate release line, installed from its own package. The installer atopencode.ai/install and the opencode-ai npm package both serve OpenCode 1. Install OpenCode 2 with one of:
opencode command, like OpenCode 1, and the two are not installed side by side by default. Remove a package-managed OpenCode 1 installation before installing OpenCode 2: the OpenCode 2 curl installer replaces the OpenCode 1 binary.
You do not need the config generator from step 2 to get started. OpenCode 2 reads its provider and model catalog from models.dev, where Eden AI is already listed, so /connect finds Eden AI and /models lists its models with no config file. Export EDENAI_API_KEY or connect the key through /connect as usual.
Only the config key changes. Where OpenCode 1 uses provider with an options object, OpenCode 2 uses providers with a settings object:
opencode.json
settings block entirely to stay on the default https://api.edenai.run/v3.
An OpenCode 1 config keeps working on OpenCode 2: it reads the older
provider key and migrates it to providers, mapping options to settings. The older key is marked deprecated in the config schema, so prefer providers for new setups.attachment and reasoning fields of each model and prints a warning for them.
Expert Models as Tools (MCP)
Eden AI also hosts an MCP server that exposes the expert model catalog (OCR, web search, speech, translation and more) as tools. Add the server toopencode.json:
mcp.servers.edenai, with disabled in place of enabled. The block above is migrated automatically.
See the MCP server page for the full tool catalog and the conventions its tools share.
Troubleshooting
401 Unauthorized
The credential is missing or wrong. Eden AI answers Invalid API key for a wrong or revoked sk-eden- key and Invalid token for a value of any other shape. Re-run /connect and paste a fresh key from app.edenai.run → API Keys, watching for leading or trailing spaces.
An Eden AI model is missing from /models
On OpenCode 1, confirm the config parses and contains the provider:
providers, read that key instead; the generator always writes 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 a key under provider.edenai.models in your config, exactly as written there. An alias keeps its ~: edenai/~gemini-flash-latest, not edenai/gemini-flash-latest. Run opencode models to see the exact strings OpenCode loaded.
Connection issues
ConfirmbaseURL is https://api.edenai.run/v3, or https://api.eu.edenai.run/v3 if you use the EU gateway, with nothing after /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: Anthropic’s official CLI on Eden AI