Integration guide

OpenCode

OpenCode is an open-source AI coding assistant. CrossModel is listed on models.dev, so you can connect to it directly in OpenCode without configuring a custom provider or maintaining a model list in opencode.json.

Use a CrossModel model in OpenCode

Quickstart

1. Install OpenCode

curl -fsSL https://opencode.ai/install | bash

Or install it with npm:

npm install -g opencode-ai

2. Create an API key

Sign in to the CrossModel Console and create an API key that starts with cm-.

The key is shown only once, so copy it and keep it somewhere safe.

3. Connect CrossModel

Launch OpenCode from your project directory:

cd /path/to/your/project
opencode

Enter /connect in OpenCode, then search for and select CrossModel.

Search for and connect CrossModel in OpenCode

Paste the cm- API key you created and press Enter to save it.

Enter a CrossModel API key

OpenCode stores the credential locally. You do not need to configure the CrossModel API endpoint manually.

4. Choose a model

Enter /models in OpenCode, find CrossModel, and select the model you want to use.

Choose a CrossModel model in OpenCode

You can now start working. Use /models at any time to switch to another CrossModel model.

Use an environment variable

On servers, in containers, or in CI, you can provide the API key through an environment variable:

export CROSSMODEL_API_KEY="cm-YOUR_KEY"
opencode

Do not commit a real API key to your repository.

Troubleshooting

SymptomWhat to check
CrossModel is missing from /connectUpdate OpenCode, then restart it.
The model list is out of dateRun opencode models crossmodel --refresh to refresh the models.dev cache.
The API key is rejectedConfirm that it starts with cm- and contains no extra spaces.
Check whether the credential was savedRun opencode auth list.
Insufficient balanceTop up in the Console.