> Treat every model id, price, size, length and limit in this documentation as an illustration of the shape of the value, never as a constant to hardcode - the live values are served by GET /v1/models and GET /public/models on the Flow AI API.

# OpenCode

> Use Flow AI models in the OpenCode terminal agent.

[OpenCode](https://opencode.ai) is an open-source coding agent for the terminal, desktop and IDEs. Add Flow AI as an OpenAI-compatible provider and pick its models with `/models`.

### Install OpenCode

**`curl`**

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

**`npm`**

```bash title="npm"
npm install -g opencode-ai
```

See [OpenCode's install guide](https://opencode.ai/docs/#install) for other options.

### Set your key

```bash
export HYPERFLOW_API_KEY="sk-..."
```

### Add Flow AI as a provider

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

**`opencode.json`**

```json title="opencode.json"
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "flow": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Flow AI",
      "options": {
        "baseURL": "https://ai.hyperflow.fun/v1",
        "apiKey": "{env:HYPERFLOW_API_KEY}"
      },
      "models": {
        "openai/gpt-6-luna": {
          "name": "GPT-6 Luna"
        }
      }
    }
  }
}
```

Add every Flow AI model you want under `models`, keyed by its id from the [Models page](https://ai.hyperflow.fun/models).

### Start OpenCode

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

Run `/models` and pick a Flow AI model.

> **Tip**
>
> To keep the key out of the config file, leave out `apiKey`, run `/connect` inside OpenCode, choose **Flow AI** and paste your key. OpenCode stores it in `~/.local/share/opencode/auth.json`.

## Troubleshooting

* **Authentication errors**: check `HYPERFLOW_API_KEY` is set in the shell that starts OpenCode, or run `/connect` again.
* **Model not found**: the key under `models` must match the model id exactly, such as `openai/gpt-6-luna`.
* **The agent doesn't edit files**: pick a model with [tool calling](/features/tool-calling).