メインコンテンツへスキップ
OpenCode (GitHub) は 多くのプロバイダーで動作するオープンソースのターミナル AI コーディング エージェントです。
プロトコル: OpenAI 互換
  • Base URL: https://api.orcarouter.ai/v1 (/v1含みます)
OpenAI プロトコル経由の Claude reasoning モデルは temperature != 1 を拒否 します (400 temperature may only be set to 1 when thinking is enabled)。 非 reasoning モデルを使うか、reasoningEffort を有効にしてください — thinking を有効化する を参照。

インストール

npm install -g opencode-ai

設定

設定ファイル: ~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "orcarouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "OrcaRouter",
      "options": { "baseURL": "https://api.orcarouter.ai/v1", "apiKey": "sk-orca-..." },
      "models": { "orcarouter/auto": { "name": "OrcaRouter Auto" } }
    }
  },
  "model": "orcarouter/orcarouter/auto"
}
お好みで特定のモデルに差し替えられます。例: google/gemini-2.5-flashanthropic/claude-opus-4.8。モデル ID は常に vendor/model 形式を使います。

実行

opencode run "Reply with exactly: OK"
期待される出力: OK

注意事項

  • base URL には /v1 を含める必要があります。
  • モデル参照は provider/model 形式を使います。プロバイダー名が orcarouter で、モデル ID にも vendor プレフィックスが付くため、参照は 3 セグメントに なります: orcarouter/orcarouter/auto (特定のモデルなら orcarouter/anthropic/claude-opus-4.8)。
VS Code 拡張機能: OpenCode 公式の VS Code 拡張機能 (sst-dev.opencode) は エディター内で CLI を実行し、同じ opencode.json を共有します — エディター内に 別個のエンドポイント設定はありません。上記のとおり一度設定すれば、拡張機能が それを読み取ります。

thinking / reasoning を有効化する

モデルの optionsreasoningEffort を設定します:
"models": {
  "anthropic/claude-sonnet-4.6": {
    "name": "Sonnet 4.6",
    "options": { "reasoningEffort": "high" }
  }
}
reasoningEffort を有効にすると、上記の temperature 警告も回避できます — 思考が有効な場合は temperature = 1 が許可されるため、400 が消えます。Anthropic ネイティブの制御には、@ai-sdk/anthropic プロバイダーが thinking: { type: "enabled", budgetTokens: N } を受け付けます。