# Use OpenCode with open models
URL: https://docs.munito.ai/opencode

Munito AI is in the provider list of OpenCode, which comes from [models.dev](https://models.dev). OpenCode runs open models through the OpenAI-compatible [Chat Completions API](https://docs.munito.ai/api/createChatCompletion).

## Connect from the provider list [#connect-from-the-provider-list]

1. Create an [API key](https://console.munito.ai/keys).
2. In OpenCode, run `/connect`, search for Munito AI, and paste the key. To keep processing in the EU, pick Munito AI (EU).
3. Run `/models` and pick a model, such as `munito/zai-org/glm-5.3-flash`, or `munito-eu/zai-org/glm-5.3-flash` on the EU host.

OpenCode keeps the key in `~/.local/share/opencode/auth.json`.
The list holds the chat models of each host. [Models and pricing](https://docs.munito.ai/models) lists every model and its regions.
OpenCode refreshes its copy of models.dev on its own, when it starts and every hour. If Munito AI is not in the list, run `opencode models --refresh`, or add the provider by hand as the next section shows.

## Add the provider by hand [#add-the-provider-by-hand]

Export the key as `MUNITO_API_KEY`:

```bash
export MUNITO_API_KEY=munitoai_...
```

Add this configuration to `~/.config/opencode/opencode.json`:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "munito/zai-org/glm-5.3-flash",
  "provider": {
    "munito": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Munito",
      "options": {
        "baseURL": "https://api.munito.ai/inference/v1",
        "apiKey": "{env:MUNITO_API_KEY}"
      },
      "models": {
        "zai-org/glm-5.3-flash": {
          "name": "GLM-5.3-Flash",
          "limit": { "context": 1048576, "output": 943718 },
          "variants": {
            "low": { "reasoningEffort": "low" },
            "high": { "reasoningEffort": "high" },
            "max": { "reasoningEffort": "max" }
          }
        }
      }
    }
  }
}
```

Run `opencode`.
The command `opencode run "<task>"` runs one task without the terminal UI.
OpenCode names a model by the provider ID and the model ID: `munito/zai-org/glm-5.3-flash`.
`{env:MUNITO_API_KEY}` reads the key from the environment, so the file holds no key.
The `limit` tells OpenCode the context window of GLM-5.3-Flash, 1,048,576 tokens, so that it compacts the conversation before the window is full.

OpenCode 1 and OpenCode 2 both read this configuration.
Munito AI tested it with OpenCode 1.19.4 and 2.1.3.
See the OpenCode docs for [custom providers](https://opencode.ai/docs/providers/#custom-provider) and for the [OpenCode 1 configuration in OpenCode 2](https://opencode.ai/v2/docs/migrate-v1#use-your-existing-configuration).

Use a [regional host](https://docs.munito.ai/regions) to keep processing in the EU.
Replace the `baseURL` with `https://api.eu.munito.ai/inference/v1`.

To add a model, add its ID and its `limit` to `models`, then select it with `/models` in OpenCode.
The page of each chat model in the [model catalog](https://docs.munito.ai/models) gives its model ID, its context and its maximum output.

## Reasoning effort [#reasoning-effort]

GLM-5.3-Flash always reasons.
The `variants` map gives OpenCode the effort levels of the model: `low`, `high` and `max`.
Without a level, the model reasons at its default effort.
Press `ctrl+t` in the terminal UI to change the level.
For one task, OpenCode 1 takes `--variant`, and OpenCode 2 takes the level after the model ID:

```bash
# OpenCode 1
opencode run --variant high "<task>"

# OpenCode 2
opencode run -m munito/zai-org/glm-5.3-flash#high "<task>"
```

Another model can declare other levels. See [Reasoning models](https://docs.munito.ai/reasoning) and the OpenCode docs for [variants](https://opencode.ai/docs/models/#variants).
