# Connect OpenCode

https://omnimodel.me/apps/opencode

> Open-source terminal coding agent; add one OpenAI-compatible provider to its config.

## Use cases

Good for an open-source agent that reads your project, edits files and runs tests from the terminal. OpenCode reaches OpenAI-compatible endpoints through `@ai-sdk/openai-compatible`, configured globally or per project.

## Tips

A coding agent sends many long requests per task, so pick a long-context model with tool calling and set a daily spend limit on the key.

## Reasoning effort

Whether a reasoning level is sent depends on the reasoning setting you give the model (`reasoning_effort` on the Chat API). The platform follows the levels the serving line accepts: a level the upstream rejects becomes the next higher accepted level, or its highest one. If the model cannot turn reasoning off, asking for it returns 422 `model.reasoning_off_unsupported`. Each model's table is under Reasoning effort on its page in the [catalog](/catalog?lang=en); rewritten calls show the rewrite in usage records.

## If it cannot connect

1. Use `https://omnimodel.me/v1` as the API host, without `/chat/completions`.
2. The key starts with `key_` and is not paused or revoked; `auth.invalid_key` means the key cannot be used.
3. The model ID matches the [catalog](/catalog) and is in the key's allowed models.
4. `billing.insufficient_credit` means the balance is too low; see [common errors](/docs/errors?lang=en) for more.

## Setup

1. Install: npm install -g opencode-ai.
2. Put the block below in ~/.config/opencode/opencode.json, or in opencode.json at a project root to scope it to that project.
3. Run opencode in your project and confirm the A2Agent model with /models.

## Settings

- API host：`https://omnimodel.me/v1`
- API key：`YOUR_API_KEY`
- Model：`MODEL_ID`

> This setup follows the OpenCode docs and has not been tested by the platform yet; if something breaks, open a ticket with the request ID.

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "a2agent": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "A2Agent",
      "options": {
        "baseURL": "https://omnimodel.me/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "MODEL_ID": {}
      }
    }
  },
  "model": "a2agent/MODEL_ID"
}
```

## FAQ

### Will the key end up in my repository?

A project-level opencode.json may be committed. Write apiKey as {env:A2AGENT_API_KEY} and export that variable in your shell instead.

### How do I use more than one model?

Add more model IDs under models and switch with /models.

