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
1
Open API Keys
Open the dashboard and go to API Keys.
2
Choose OpenCode
Find the key you want to use for OpenCode, click Use key, then choose OpenCode.
3
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.4
Write the config file
For global use, write it to
~/.config/opencode/opencode.json. For project-only use, write it to opencode.json in the project root.Config file paths
Create the file manually if it does not exist. Project config has higher precedence than global config.
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.