Skip to main content
OpenCode can connect to 4096bytes through an OpenAI-compatible Provider. Write the dashboard-generated 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 --version works.
  • The Use key dialog is open for the API Key you want to use.
The API Key in opencode.json is stored as a local plaintext credential. Do not commit config files, screenshots, or terminal output that include a full API Key.

Install

If OpenCode is not installed, check the latest instructions in the OpenCode documentation. macOS or Linux:
If you use npm for global CLI tools:
After installation, reopen the terminal and verify:

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:
After OpenCode opens, start with a low-risk prompt:
If OpenCode responds without authentication or model errors, the config is active.

Common issues

Check that opencode.json is valid JSON. Confirm apiKey has no missing characters, newlines, or extra spaces.
The model ID must match the model name shown in the dashboard. Do not copy names from someone else’s screenshot.
Confirm you edited the file OpenCode is actually reading. A project-root opencode.json overrides matching fields in global config.
Yes, but /connect only stores credentials. Provider, Base URL, and model list should still come from the dashboard-generated opencode.json.