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

# OpenCode

> Configure OpenCode to use Capriole AI.

## What is OpenCode

OpenCode is an open-source AI coding agent available as a terminal interface, desktop app, and IDE extension. With provider configuration, it can send supported model requests through Capriole AI's OpenAI-compatible and Anthropic-compatible endpoints.

## Prerequisites

Before you begin, make sure you have:

* A Capriole AI account ([Sign up here](https://capriole.ai))
* A Capriole AI API key ([Get your key](https://capriole.ai?view=api))

## Installation

Install OpenCode with the official install script:

```bash theme={null}
curl -fsSL https://opencode.ai/install | bash
```

Or install it with npm:

```bash theme={null}
npm install -g opencode-ai
```

Verify the install:

```bash theme={null}
opencode --version
```

## Configuration

Create or update `~/.config/opencode/opencode.json`:

Use `apiKey` for the OpenAI provider and `authToken` for the Anthropic provider.

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "model": "capriole-ai-openai/openai-latest",
  "small_model": "capriole-ai-openai/openai-latest",
  "enabled_providers": ["capriole-ai-openai", "capriole-ai-anthropic"],
  "provider": {
    "capriole-ai-openai": {
      "npm": "@ai-sdk/openai",
      "name": "Capriole AI OpenAI",
      "options": {
        "baseURL": "https://api.caprioletech.com/v1",
        "apiKey": "YOUR_CAPRIOLE_AI_API_KEY"
      },
      "models": {
        "openai-latest": {
          "name": "OpenAI latest",
          "options": {
            "forceReasoning": true
          },
          "variants": {
            "minimal": {
              "reasoningEffort": "minimal",
              "reasoningSummary": "auto"
            },
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "auto"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "auto"
            }
          }
        },
        "openai/gpt-5.5": {
          "name": "GPT 5.5",
          "options": {
            "forceReasoning": true
          },
          "variants": {
            "minimal": {
              "reasoningEffort": "minimal",
              "reasoningSummary": "auto"
            },
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "auto"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "auto"
            }
          }
        },
        "openai/gpt-5.4-mini": {
          "name": "GPT 5.4 mini",
          "options": {
            "forceReasoning": true
          },
          "variants": {
            "minimal": {
              "reasoningEffort": "minimal",
              "reasoningSummary": "auto"
            },
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "auto"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "auto"
            }
          }
        }
      }
    },
    "capriole-ai-anthropic": {
      "npm": "@ai-sdk/anthropic",
      "name": "Capriole AI Anthropic",
      "options": {
        "baseURL": "https://api.caprioletech.com/v1",
        "authToken": "YOUR_CAPRIOLE_AI_API_KEY"
      },
      "models": {
        "claude-latest": {
          "name": "Claude latest",
          "variants": {
            "low": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "low"
            },
            "medium": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "medium"
            },
            "high": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "high"
            },
            "xhigh": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "xhigh"
            },
            "max": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "max"
            }
          }
        },
        "claude-opus-4-8": {
          "name": "Opus 4.8",
          "variants": {
            "low": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "low"
            },
            "medium": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "medium"
            },
            "high": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "high"
            },
            "xhigh": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "xhigh"
            },
            "max": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "max"
            }
          }
        },
        "claude-opus-4-7": {
          "name": "Opus 4.7",
          "variants": {
            "low": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "low"
            },
            "medium": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "medium"
            },
            "high": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "high"
            },
            "xhigh": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "xhigh"
            },
            "max": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "max"
            }
          }
        },
        "claude-opus-4-6": {
          "name": "Opus 4.6",
          "variants": {
            "low": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "low"
            },
            "medium": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "medium"
            },
            "high": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "high"
            },
            "xhigh": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "xhigh"
            },
            "max": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "max"
            }
          }
        },
        "claude-sonnet-4-6": {
          "name": "Sonnet 4.6",
          "variants": {
            "low": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "low"
            },
            "medium": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "medium"
            },
            "high": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "high"
            },
            "xhigh": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "xhigh"
            },
            "max": {
              "thinking": {
                "type": "adaptive",
                "display": "summarized"
              },
              "effort": "max"
            }
          }
        }
      }
    }
  }
}
```

## Run OpenCode

After replacing `YOUR_CAPRIOLE_AI_API_KEY` in the config, start OpenCode:

```bash theme={null}
opencode
```

Use `/models` to select OpenAI latest, GPT 5.5, GPT 5.4 mini, Claude latest, Opus 4.8, Opus 4.7, Opus 4.6, or Sonnet 4.6. Use `Ctrl+T` to cycle model variants.

## Supported models

OpenCode supports OpenAI latest, GPT 5.5, GPT 5.4 mini, Claude latest, Opus 4.8, Opus 4.7, Opus 4.6, and Sonnet 4.6 through Capriole AI. Use `openai-latest` and `claude-latest` for new setups.

* `openai-latest`
* `openai/gpt-5.5`
* `openai/gpt-5.4-mini`
* `claude-latest`
* `claude-opus-4-8`
* `claude-opus-4-7`
* `claude-opus-4-6`
* `claude-sonnet-4-6`

## Troubleshooting

### Why does OpenCode return an authentication error?

Confirm that both `apiKey` and `authToken` in `~/.config/opencode/opencode.json` use your Capriole AI API key instead of `YOUR_CAPRIOLE_AI_API_KEY`.

### Why do GPT requests fail?

Confirm that the GPT provider uses `npm: "@ai-sdk/openai"` and `baseURL: "https://api.caprioletech.com/v1"` so requests use the Responses API.

### Why do Anthropic requests fail?

Confirm that the Anthropic provider uses `npm: "@ai-sdk/anthropic"`, `authToken`, and `baseURL: "https://api.caprioletech.com/v1"`.

### Why don't Capriole AI models appear?

Confirm that the model reference uses `<providerId>/<modelId>`, such as `capriole-ai-openai/openai-latest` or `capriole-ai-anthropic/claude-latest`, and that `enabled_providers` includes the Capriole AI providers while `disabled_providers` does not block them.

### Why don't model variants appear?

Confirm that you restarted OpenCode after updating `~/.config/opencode/opencode.json`, then open `/models` and press `Ctrl+T` to cycle variants.

### Why don't config changes apply?

Check for project-level `opencode.json` or `OPENCODE_CONFIG` overrides, then restart OpenCode.

### Why do provider initialization or provider package errors appear?

For `ProviderInitError`, verify the provider config first. For provider package errors, clear `~/.cache/opencode` and restart OpenCode so provider packages are reinstalled.

## Notes

* The Anthropic provider uses `authToken` so the AI SDK Anthropic provider sends `Authorization: Bearer` authentication.
* OpenCode variants are client-side model settings. They do not create new Capriole AI API model IDs.
* Official references: [OpenCode install](https://opencode.ai/docs), [OpenCode config](https://opencode.ai/docs/config), [OpenCode providers](https://opencode.ai/docs/providers), [OpenCode models and variants](https://opencode.ai/docs/models), [OpenCode keybinds](https://opencode.ai/docs/keybinds), [OpenCode troubleshooting](https://opencode.ai/docs/troubleshooting), [OpenAI Responses API](https://developers.openai.com/api/reference/resources/responses/methods/create), [AI SDK OpenAI provider](https://ai-sdk.dev/v7/providers/ai-sdk-providers/openai), [AI SDK Anthropic provider](https://ai-sdk.dev/v7/providers/ai-sdk-providers/anthropic), [Anthropic adaptive thinking](https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking), and [Anthropic effort](https://platform.claude.com/docs/en/build-with-claude/effort).
