Skip to main content
Configure OpenCode, the AI-powered terminal coding assistant, to use Eden AI for access to 500+ models.

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.runAPI Keys

Setup

1. Install OpenCode

2. Generate your config

Save the script below as gen_opencode_config.py and run it:
It fetches Eden AI’s catalog, keeps every model that supports function calling, and adds an 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.
Each generated model entry carries the metadata OpenCode needs: 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.
Prefer an environment variable? Skip /connect and add "apiKey": "{env:EDENAI_API_KEY}" next to baseURL in the edenai provider’s options, then export EDENAI_API_KEY in your shell.

4. Pick a model and start coding

Run /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.runAPI 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:
Restart OpenCode after regenerating the file — the config is read at startup.

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

Confirm baseURL 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