opencode.json config into an OpenCode config file.
Prefer copying the config from the dashboard Use key dialog. The OpenCode tab inserts the current API Key, Base URL, and model names in OpenCode format.
Prerequisites
- You have completed Create an account.
- You have completed Get an API Key.
- OpenCode is installed and
opencode --versionworks. - The Use key dialog is open for the API Key you want to use.
Install
If OpenCode is not installed, check the latest instructions in the OpenCode documentation. macOS or Linux:Copy config from the dashboard
Copy config
Copy the generated
opencode.json content. The sample is only a reference. Use the Base URL, API Key, and model names shown in your dashboard.Config file paths
| Scope | Path | Use case |
|---|---|---|
| Global config | ~/.config/opencode/opencode.json | Use 4096bytes by default in all projects. |
| Project config | opencode.json | Use this config only in the current project. |
Verify
Save the config, go to a project directory, and run:Common issues
OpenCode reports authentication failure
OpenCode reports authentication failure
Check that
opencode.json is valid JSON. Confirm apiKey has no missing characters, newlines, or extra spaces.OpenCode cannot find the model
OpenCode cannot find the model
The model ID must match the model name shown in the dashboard. Do not copy names from someone else’s screenshot.
The config does not take effect
The config does not take effect
Confirm you edited the file OpenCode is actually reading. A project-root
opencode.json overrides matching fields in global config.Can I configure the API Key with /connect?
Can I configure the API Key with /connect?
Yes, but
/connect only stores credentials. Provider, Base URL, and model list should still come from the dashboard-generated opencode.json.