# OpenCode

Use Aurora as a custom provider in [OpenCode](https://opencode.ai/), a terminal
coding agent. This configuration selects the OpenAI-compatible Chat Completions
adapter and assigns both the main and small helper model to Aurora.

> Available Inference endpoint: `https://ai.aur.lu/v1` (Aurora).

## Install and prepare

Install OpenCode using its [installation guide](https://opencode.ai/docs/), then
create an [Aurora API token](https://docs.aur.lu/docs/inference/getting-started) and check the
[model catalog](https://docs.aur.lu/docs/inference/integrations#discover-models-and-verify-authentication).

```bash
export AURORA_API_TOKEN="<your-token>"
```

## Configure the provider

Create `opencode.json` in your project, or use
`~/.config/opencode/opencode.json` for all projects. Merge these keys into an
existing configuration:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "aurora/deepseek/deepseek-v4-flash",
  "small_model": "aurora/deepseek/deepseek-v4-flash",
  "provider": {
    "aurora": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Aurora Inference",
      "options": {
        "baseURL": "https://ai.aur.lu/v1",
        "apiKey": "{env:AURORA_API_TOKEN}"
      },
      "models": {
        "deepseek/deepseek-v4-flash": {
          "name": "DeepSeek V4 Flash"
        }
      }
    }
  }
}
```

The `aurora/` prefix selects the local provider. The remaining
`deepseek/deepseek-v4-flash` is the exact model ID sent to Aurora. The base URL
already includes `/v1`; OpenCode appends `/chat/completions`.

To store the credential through OpenCode instead, omit `options.apiKey`, start
OpenCode, run `/connect`, select **Other**, use `aurora` as the provider ID, and
paste your Aurora token. The credential provider ID must match the config key.

## Start a session

From your project directory, in the shell where you exported the token:

```bash
opencode
```

Run `/models` and select **Aurora Inference → DeepSeek V4 Flash**. Ask:

```text
Read README.md and summarize the project in three bullets. Do not edit files.
```

Use a different existing text file if the project has no README. Expect a file
read followed by a summary of that file. OpenCode handles response streaming.
For a one-shot check:

```bash
opencode run --model aurora/deepseek/deepseek-v4-flash "Say hello in one sentence."
```

## Troubleshooting

- **Provider missing:** Check the configuration location, JSON syntax, and that
  the token is available through the environment or `/connect`.
- **Model not found:** The model-map key is the Aurora ID; the top-level `model`
  and `small_model` include the additional `aurora/` provider prefix.
- **Authentication works only in the terminal:** A desktop-launched instance may
  not inherit the token. Use `/connect` in that instance.
- **Tool calls fail:** Check the model's tool support and test a simple file read.
  Use the [shared troubleshooting guide](https://docs.aur.lu/docs/inference/integrations#troubleshooting)
  to distinguish a request error from an agent permission or tool error.

Upstream references: [Custom providers](https://opencode.ai/docs/providers/#custom-provider),
[configuration](https://opencode.ai/docs/config/).
