Skip to main content
OpenCode already includes a built-in GitHub Copilot provider, so you do not need this integration for basic usage. Use it when you want OpenCode to communicate with Copilot using Anthropic Messages semantics end-to-end — which preserves native tool_use / tool_result flows, reduces unnecessary premium request consumption, and enables Claude-native beta features like interleaved-thinking and advanced-tool-use that are unavailable through the plain Chat Completions path.

When to use this integration

Use this integration instead of OpenCode’s built-in Copilot provider when you want:
  • Anthropic Messages semantics — requests stay in the native Messages API format rather than being translated to Chat Completions
  • Premium request optimizations — warmup and tool-continuation traffic is routed to a small model to avoid spending premium quota
  • Claude-native beta featuresinterleaved-thinking, advanced-tool-use, and context-management betas that require the Messages API path
  • Phase-aware gpt-5.4 commentary — the model emits a short user-facing update before tool calls so long-running actions are easier to follow

Start the proxy

Start Copilot API using the OpenCode OAuth app. This approach uses the same OAuth credentials as OpenCode’s built-in Copilot provider, which means there is no additional Terms of Service risk:
npx @nick3/copilot-api@latest --oauth-app=opencode start

Configure OpenCode

Add the following provider configuration to ~/.config/opencode/opencode.json. This tells OpenCode to use the @ai-sdk/anthropic npm package as the AI SDK provider, pointing it at the local proxy:
{
  "$schema": "https://opencode.ai/config.json",
  "model": "local/gpt-5.4",
  "small_model": "local/gpt-5-mini",
  "agent": {
    "build": {
      "model": "local/gpt-5.4"
    },
    "plan": {
      "model": "local/gpt-5.4"
    },
    "explore": {
      "model": "local/gpt-5-mini"
    }
  },
  "provider": {
    "local": {
      "npm": "@ai-sdk/anthropic",
      "name": "Copilot API Proxy",
      "options": {
        "baseURL": "http://localhost:4141/v1",
        "apiKey": "dummy"
      },
      "models": {
        "gpt-5.4": {
          "name": "gpt-5.4",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 272000,
            "output": 128000
          }
        },
        "gpt-5-mini": {
          "name": "gpt-5-mini",
          "limit": {
            "context": 128000,
            "output": 64000
          }
        },
        "claude-sonnet-4.6": {
          "id": "claude-sonnet-4.6",
          "name": "claude-sonnet-4.6",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 128000,
            "output": 32000
          },
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 31999
            }
          }
        }
      }
    }
  }
}

Key configuration fields

FieldValueWhy it matters
npm"@ai-sdk/anthropic"Tells OpenCode to use the Anthropic SDK — requests use Anthropic Messages semantics instead of OpenAI Chat Completions
options.baseURL"http://localhost:4141/v1"Points the Anthropic SDK at the local proxy; the SDK appends /messages, /models, and /messages/count_tokens automatically
options.apiKey"dummy"The Anthropic SDK requires a non-empty key; any placeholder works unless you configure auth.apiKeys in the proxy
model / agent.build.model / agent.plan.model"local/gpt-5.4"Routes build and plan work to the full-capability model
small_model / agent.explore.model"local/gpt-5-mini"Routes exploration and background work to a cheaper fast model to preserve premium quota
If you configure auth.apiKeys in config.json, replace "dummy" with one of your configured keys. Otherwise any non-empty placeholder is fine.
Add the following reminders to your AGENTS.md file. They instruct the model to use the question tool for user interactions rather than outputting free-form questions:
- Prohibited from directly asking questions to users, MUST use question tool.
- Once you can confirm that the task is complete, MUST use question tool to make user confirm. The user may respond with feedback if they are not satisfied with the result, which you can use to make improvements and try again, after try again, MUST use question tool to make user confirm again.

Install the OpenCode plugin

Install the subagent marker plugin to enable session tracking and correct subagent classification. The plugin prepends a session marker to subagent chat messages and sets a session ID header, which lets the proxy preserve root session context and correctly classify subagent-originated traffic. See the Plugin Integrations guide for installation instructions.