> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Connect OpenCode to the Phaseo Gateway with a custom OpenAI-compatible provider.

OpenCode can call Phaseo through a custom OpenAI-compatible provider. Use this setup when you want OpenCode model selection, usage, and routing to go through one Phaseo API key.

## Prerequisites

* A Phaseo API key.
* OpenCode installed locally.

## 1) Set your API key

```bash theme={null}
export PHASEO_API_KEY="your_phaseo_api_key"
```

```powershell theme={null}
$env:PHASEO_API_KEY = "your_phaseo_api_key"
```

## 2) Add an OpenCode provider

Create or update `opencode.json` in your project, or your global OpenCode config:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "model": "phaseo/openai/gpt-5.5",
  "provider": {
    "phaseo": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Phaseo",
      "options": {
        "baseURL": "https://api.phaseo.ai/v1",
        "apiKey": "{env:PHASEO_API_KEY}"
      },
      "models": {
        "openai/gpt-5.5": {
          "name": "GPT-5.5"
        },
        "openai/gpt-5.4-mini": {
          "name": "GPT-5.4 Mini"
        },
        "anthropic/claude-sonnet-4.5": {
          "name": "Claude Sonnet 4.5"
        }
      }
    }
  }
}
```

Add or remove models from the `models` object to match the Phaseo model ids you want in OpenCode.

## 3) Start OpenCode

Restart OpenCode after editing the config, then choose the Phaseo model from `/models`.

## Verification

* Run a small prompt before using file-editing workflows.
* If a model is rejected, confirm the exact id with the [Models endpoint](../../api-reference/endpoint/models.mdx).
* If authentication fails, confirm `PHASEO_API_KEY` is set in the same shell that starts OpenCode.

## Add docs context

To let OpenCode read Phaseo docs during a session, add the [Docs MCP](./docs-mcp.mdx) server as well.
