---
title: OpenCode
---

[OpenCode](https://opencode.ai) is an open-source AI coding assistant. CrossModel is listed on [models.dev](https://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](/integrations/opencode/connected-hero.png)

## Quickstart

### 1. Install OpenCode

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

Or install it with npm:

```bash
npm install -g opencode-ai
```

### 2. Create an API key

Sign in to the [CrossModel Console](/console/api-keys) 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:

```bash
cd /path/to/your/project
opencode
```

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

![Search for and connect CrossModel in OpenCode](/integrations/opencode/connect-crossmodel.png)

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

![Enter a CrossModel API key](/integrations/opencode/enter-api-key.png)

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](/integrations/opencode/select-model.png)

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:

```bash
export CROSSMODEL_API_KEY="cm-YOUR_KEY"
opencode
```

Do not commit a real API key to your repository.

## Troubleshooting

| Symptom | What to check |
|---------|---------------|
| CrossModel is missing from `/connect` | Update OpenCode, then restart it. |
| The model list is out of date | Run `opencode models crossmodel --refresh` to refresh the models.dev cache. |
| The API key is rejected | Confirm that it starts with `cm-` and contains no extra spaces. |
| Check whether the credential was saved | Run `opencode auth list`. |
| Insufficient balance | Top up in the [Console](/console/billing). |
