> For the complete documentation index, see [llms.txt](https://docs.gooey.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gooey.ai/api-reference/ai-coding-agents/opencode.md). Agents can also search and read this documentation through its [MCP server](https://docs.gooey.ai/~gitbook/mcp).

# OpenCode Setup

Install OpenCode and configure it to use Gooey.AI models.

Setup takes about five minutes on a Mac.

## 1. Install OpenCode

Choose either option:

* **App:** Download OpenCode from <https://opencode.ai/download>. On an M1, M2, M3, or M4 Mac, choose **Apple Silicon**. Open the downloaded file and drag OpenCode into Applications. Do not open it yet.
* **Terminal:** Run:

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

## 2. Add the Gooey.AI settings

Run this block in Terminal. It backs up an existing global `opencode.json` or `opencode.jsonc` file by adding `.bak`, then writes the Gooey.AI configuration.

{% hint style="warning" %}
If your existing OpenCode configuration contains providers, plugins, permissions, or other settings you need, merge the `gooey` provider into that file instead of replacing it.
{% endhint %}

{% code overflow="wrap" %}

```bash
mkdir -p ~/.config/opencode && for f in opencode.json opencode.jsonc; do [ -f ~/.config/opencode/$f ] && mv ~/.config/opencode/$f ~/.config/opencode/$f.bak; done; cat > ~/.config/opencode/opencode.jsonc <<'EOF'
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "gooey": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Gooey.AI",
      "options": {
        "baseURL": "https://gooey-litellm-prod.az-westus3-1.gooey.ai/v1",
        "apiKey": "{file:~/.config/opencode/gooey.key}"
      },
      "models": {
        "gpt-5.6":             { "name": "GPT-5.6",             "reasoning": true, "limit": { "context": 1050000, "output": 128000 } },
        "gpt-5.6-sol":         { "name": "GPT-5.6 Sol",         "reasoning": true, "limit": { "context": 1050000, "output": 128000 } },
        "gpt-5.6-terra":       { "name": "GPT-5.6 Terra",       "reasoning": true, "limit": { "context": 1050000, "output": 128000 } },
        "gpt-5.6-luna":        { "name": "GPT-5.6 Luna",        "reasoning": true, "limit": { "context": 1050000, "output": 128000 } },
        "gpt-5.5":             { "name": "GPT-5.5",             "reasoning": true, "limit": { "context": 1050000, "output": 128000 } },
        "gpt-5.4":             { "name": "GPT-5.4",             "reasoning": true, "limit": { "context": 1050000, "output": 128000 } },
        "gpt-5.4-mini":        { "name": "GPT-5.4 mini",        "reasoning": true, "limit": { "context": 272000,  "output": 128000 } },
        "gpt-5.4-nano":        { "name": "GPT-5.4 nano",        "reasoning": true, "limit": { "context": 272000,  "output": 128000 } },
        "gpt-5.2":             { "name": "GPT-5.2",             "reasoning": true, "limit": { "context": 272000,  "output": 128000 } },
        "gpt-5.1":             { "name": "GPT-5.1",             "reasoning": true, "limit": { "context": 272000,  "output": 128000 } },
        "gpt-5":               { "name": "GPT-5",               "reasoning": true, "limit": { "context": 272000,  "output": 128000 } },
        "gpt-5-mini":          { "name": "GPT-5 mini",          "reasoning": true, "limit": { "context": 272000,  "output": 128000 } },
        "gpt-5-nano":          { "name": "GPT-5 nano",          "reasoning": true, "limit": { "context": 272000,  "output": 128000 } },
        "gpt-5.3-chat-latest": { "name": "GPT-5.3 Chat",                           "limit": { "context": 128000,  "output": 16384 } },
        "gpt-5.2-chat-latest": { "name": "GPT-5.2 Chat",                           "limit": { "context": 128000,  "output": 16384 } },
        "gpt-4.1":             { "name": "GPT-4.1",                                "limit": { "context": 1047576, "output": 32768 } },
        "gpt-4.1-mini":        { "name": "GPT-4.1 mini",                           "limit": { "context": 1047576, "output": 32768 } },
        "gpt-4.1-nano":        { "name": "GPT-4.1 nano",                           "limit": { "context": 1047576, "output": 32768 } },
        "gpt-4o":              { "name": "GPT-4o",                                 "limit": { "context": 128000,  "output": 16384 } },
        "gpt-4o-mini":         { "name": "GPT-4o mini",                            "limit": { "context": 128000,  "output": 16384 } },
        "o3":                  { "name": "o3",                  "reasoning": true, "limit": { "context": 200000,  "output": 100000 } },
        "o4-mini":             { "name": "o4-mini",             "reasoning": true, "limit": { "context": 200000,  "output": 100000 } },
        "o3-mini":             { "name": "o3-mini",             "reasoning": true, "limit": { "context": 200000,  "output": 100000 } },
        "o1":                  { "name": "o1",                  "reasoning": true, "limit": { "context": 200000,  "output": 100000 } }
      }
    }
  },
  "model": "gooey/gpt-4.1-mini",
  "small_model": "gooey/gpt-4.1-mini"
}
EOF
echo "✅ Settings saved"
```

{% endcode %}

## 3. Add your Gooey.AI API key

1. Go to <https://gooey.ai/account/api-keys/> and sign in.
2. Click **＋ Create new API Key**, then **Copy Secret Key**.
3. Without copying anything else, run:

{% code overflow="wrap" %}

```bash
pbpaste | tr -d '[:space:]' > ~/.config/opencode/gooey.key && chmod 600 ~/.config/opencode/gooey.key && grep -q '^sk-' ~/.config/opencode/gooey.key && echo "✅ Key saved" || echo "❌ That's not a Gooey key. Copy it again and rerun this."
```

{% endcode %}

The key is stored outside your project with owner-only permissions. Never commit or share it.

## 4. Start using OpenCode

* **App:** Open OpenCode. If it was already running, quit it with **⌘ Q** and reopen it. Open a folder and enter a message. The model picker should show **Gooey.AI**, with **GPT-4.1 mini** selected.
* **Terminal:** Run `opencode` in any folder. Enter `/models` to switch models.

## Troubleshooting

| What you see                  | Fix                                                                                               |
| ----------------------------- | ------------------------------------------------------------------------------------------------- |
| No Gooey.AI models            | Quit OpenCode fully with **⌘ Q** and reopen it. In Terminal, also run `opencode service restart`. |
| A `401` or API-key error      | Repeat step 3 with a freshly copied key.                                                          |
| `command not found: opencode` | Close Terminal, open a new window, and try again.                                                 |
| Another error                 | Capture the error without exposing your API key and send it to the Gooey.AI team.                 |
