> How to use Claude in OpenCode: the new Claude Agent provider on your Claude plan, API keys, Console, Copilot and OpenRouter, with costs and limits.
>
> Web page: https://balazscsorba.com/blog/claude-in-opencode · Language: English · Also available in: [Deutsch](https://balazscsorba.com/de/blog/claude-in-opencode.md) · [Magyar](https://balazscsorba.com/hu/blog/claude-in-opencode.md)
> Author: Balázs Csorba · Published: 2026-10-30 · Keywords: claude in opencode, opencode claude, opencode claude agent, opencode claude subscription, opencode claude max, opencode anthropic api key, claude agent sdk opencode, opencode claude code login, opencode github copilot claude, opencode zen claude pricing

[Blog](https://balazscsorba.com/blog)/[AI agents](https://balazscsorba.com/blog/category/agents)

# Claude in OpenCode: the Claude Agent provider, API keys and the other routes

How to use Claude in OpenCode: the new Claude Agent provider on your Claude plan, API keys, Console, Copilot and OpenRouter, with costs and limits.

[Balázs Csorba](https://balazscsorba.com/about)·October 30, 2026·12 min read

-   OpenCode
-   [Claude Code](https://balazscsorba.com/blog/tag/claude-code)
-   Claude Agent SDK
-   [Coding agents](https://balazscsorba.com/blog/tag/coding-agents)
-   LLM pricing

![Claude in OpenCode: a hand plugs one of two adapters into a laptop that shows a terminal window.](https://balazscsorba.com/images/blog/claude-in-opencode/cover.webp?v=872e84955c)

## Key takeaways

-   Since OpenCode 2.2.3 (October 30, 2026), the built-in Claude Agent provider runs Claude through your own Claude Code login: install Claude Code, run claude auth login, then pick Claude Agent in /connect.
-   Claude Code makes the model calls, and OpenCode does everything else: Claude gets OpenCode’s tools, permission rules, instructions, compaction and subagents instead of Claude Code’s own.
-   Anthropic’s terms forbid third-party apps from collecting or intermediating Claude.ai logins, but allow signing in to the unmodified Claude Code program with your own subscription. That is the line between the Claude Agent provider and the old Pro/Max plugins.
-   For servers, CI, teams and remote workspaces, pay per token: an Anthropic API key, OpenCode Console, Bedrock or Vertex. Copilot, OpenRouter and the Haiku-only Go plan are the other routes.
-   In my test, a small bug fix with Haiku 5.5 took three steps and about five seconds through both Claude Agent and OpenCode Go, roughly $0.003 at list prices.

On this page

1.  [Which routes are there to run Claude in OpenCode?](https://balazscsorba.com/#which-routes)
2.  [How do you set up the Claude Agent provider?](https://balazscsorba.com/#claude-agent-setup)
3.  [What happens when OpenCode runs Claude through Claude Code?](https://balazscsorba.com/#how-claude-agent-works)
4.  [Is it allowed to use your Claude subscription in OpenCode?](https://balazscsorba.com/#is-it-allowed)
5.  [When is an API key or OpenCode Console the better choice?](https://balazscsorba.com/#api-key-and-console)
6.  [Can you use Claude through Copilot, OpenRouter, Bedrock or Vertex?](https://balazscsorba.com/#copilot-openrouter-cloud)
7.  [What did a small test run show?](https://balazscsorba.com/#hands-on-test)
8.  [How do you set models and effort for Claude in OpenCode?](https://balazscsorba.com/#configure-models)
9.  [What does not work with Claude Agent in OpenCode?](https://balazscsorba.com/#limitations)
10.  [Which route should you choose?](https://balazscsorba.com/#which-to-choose)
11.  [Sources](https://balazscsorba.com/#sources)

Listen to this article

0:00

You can use Claude in OpenCode in two different ways. Since OpenCode 2.2.3, released on October 30, 2026, the built-in **Claude Agent** provider runs Claude through your own Claude Code login: install Claude Code, run `claude auth login`, choose Claude Agent in `/connect`, and Claude models work on your Claude plan while OpenCode keeps its own tools, permissions and session history. The other way is to pay per token or per seat through a provider: an Anthropic API key, OpenCode Console, GitHub Copilot, OpenRouter, or Amazon Bedrock and Google Vertex.

What you should not use are the older community plugins that log OpenCode in with your Claude Pro or Max account directly. OpenCode stopped bundling them in version 1.3.0, its docs say Anthropic explicitly prohibits them, and Anthropic’s terms forbid third-party apps from collecting or intermediating Claude.ai credentials. This guide covers each route, how the Claude Agent provider works under the hood, what the routes cost, and what a small test run on my machine showed. My [OpenCode review](https://balazscsorba.com/blog/opencode) covers the agent itself.

## Which routes are there to run Claude in OpenCode?

As of October 2026 there are seven practical routes. `opencode models` lists the Claude models of every connected provider; on my machine five providers offered Claude, from `claude-agent/opus` to `openrouter/anthropic/claude-sonnet-5.5`.

Route

Sign-in

Who bills

Example model ID

Claude Agent

Claude Code login (`claude auth login`)

Your Claude plan, or the key Claude Code uses

`claude-agent/sonnet`

Anthropic

API key

Anthropic, per token

`anthropic/claude-sonnet-5-5`

OpenCode Console

Console API key

OpenCode, prepaid per token

`opencode/claude-sonnet-5-5`

OpenCode Go

Go subscription

OpenCode, $10 a month, Haiku 5.5 only

`opencode-go/claude-haiku-5-5`

GitHub Copilot

GitHub device login

Your Copilot plan

`github-copilot/claude-sonnet-5.5`

OpenRouter

OpenRouter key

OpenRouter credits

`openrouter/anthropic/claude-sonnet-5.5`

Bedrock, Vertex

AWS or Google credentials

Your cloud account

depends on the account

The model IDs follow each provider’s conventions. Claude Agent uses Claude Code’s aliases such as `opus`, `sonnet` and `haiku`, and Claude Code resolves them to the current model, for example `claude-opus-5-5` for `opus`. Copilot and OpenRouter write versions with a dot, as in `claude-sonnet-5.5`; the Anthropic provider and OpenCode Console use hyphens, as in `claude-sonnet-5-5`.

## How do you set up the Claude Agent provider?

You need Claude Code 2.1.248 or later, signed in, on the same machine as the OpenCode server. Then you connect Claude Agent like any other provider. The model list comes from Claude Code, and effort levels are variants such as `claude-agent/opus#high`.

Text

```
# 1. Install or update Claude Code (2.1.248 or later), then sign in
claude update
claude auth login

# 2. In the OpenCode TUI: connect the provider and pick a model
/connect     # choose Claude Agent
/models      # for example claude-agent/sonnet

# 3. Or run it from the shell, with an effort variant
opencode run -m "claude-agent/opus#high" "Explain why tests/api fails"
```

OpenCode looks for `claude` on the `PATH`. To use another copy, set `OPENCODE_CLAUDE_PATH` on the OpenCode server, for example with `opencode service set env OPENCODE_CLAUDE_PATH /opt/claude/bin/claude`. Version 2.2.4, released the same day as 2.2.3, added a guided setup to the desktop and web app: choosing Claude Agent shows the `claude auth login` command, an install button for Claude Code, and a check that waits until OpenCode has confirmed that Claude Code is installed and signed in. When the check fails, the dialog names the reason, such as not installed, not signed in or too old, and offers to check again.

Any Claude Code login works, not only a subscription. If Claude Code is signed in with an API key, or set up for Claude Platform on AWS, Bedrock, Vertex or Microsoft Foundry, the provider uses that login. Connection settings in OpenCode’s config are passed on to Claude Code: `settings.baseURL` becomes `ANTHROPIC_BASE_URL`, `settings.apiKey` becomes `ANTHROPIC_API_KEY`, and `headers` become `ANTHROPIC_CUSTOM_HEADERS`. That is how you send the provider through a company LLM gateway.

## What happens when OpenCode runs Claude through Claude Code?

Claude Code makes the model calls, and OpenCode does everything else. OpenCode starts your installed `claude` program through Anthropic’s Claude Agent SDK, with one long-running process per session, and gives it OpenCode’s tools instead of Claude Code’s own. When Claude calls a tool, the provider holds the call, OpenCode runs it with its normal permission prompts, and the result goes back to Claude. The design spec states that OpenCode never sits between Claude Code and Anthropic, never changes Claude Code’s requests and never reads Claude Code’s saved login.

![OpenCode running Claude via Claude Code: Prompts go via the Agent SDK and your claude login; tool calls return to OpenCode.](https://balazscsorba.com/images/blog/claude-in-opencode/diagram-13.webp?v=08bfce140e)

OpenCode starts your installed claude program through the Claude Agent SDK, one process per session. Claude Code sends the request to Anthropic with your own login, so usage counts against your plan. When Claude calls a tool, the provider holds the call and OpenCode runs it with its own permission rules, then returns the result to Claude.

The provider deliberately switches off most of Claude Code’s own machinery so that OpenCode behaves the same whichever model you pick:

-   **Tools:** Claude Code’s built-in tools are off. Claude only gets OpenCode’s tools, so a single permission system applies and the history looks the same whichever model wrote it.
-   **Settings:** Claude Code reads none of your `~/.claude` settings, CLAUDE.md files, hooks, MCP servers or skills. OpenCode adds its own instructions on top of Claude Code’s system prompt: the selected agent’s prompt, AGENTS.md files, skills and MCP instructions.
-   **History:** OpenCode’s history is the source of truth. When you switch to Claude in the middle of a session, everything Claude has not seen is sent as one message, so you can move between Claude and other models in the same session.
-   **Compaction and subagents:** OpenCode runs both. Claude Code’s auto compaction, auto memory and tool search are off.
-   **Process lifetime:** the `claude` process stops after 5 minutes idle, and the next message resumes the saved Claude session. Time spent running OpenCode tools does not count as idle.

One practical consequence is that tool calls run one at a time. According to the spec, the provider has to match each result to Claude’s call ID and only tracks one ID at a time, so it never marks tools as safe to run in parallel.

## Is it allowed to use your Claude subscription in OpenCode?

Using the Claude Agent provider with your own subscription fits Anthropic’s published rules as of October 2026; plugins that reuse your Claude.ai login do not. The difference is who handles the credentials. Anthropic’s legal page says OAuth sign-in is intended for subscribers and for ordinary use of Claude Code and other native Anthropic applications. It does not permit third-party developers to offer Claude.ai login in their own apps, to route requests through Free, Pro, Max or Ultra plan credentials on behalf of their users, or to collect, store or intermediate Claude.ai credentials or session tokens. The same section says this does not prevent an end user from signing in to the unmodified Claude Code binary with their own Claude subscription.

The Claude Agent provider is built along exactly that line: it runs your own, unmodified `claude`, and you sign in through Anthropic’s flow in your terminal. Anthropic’s help center, updated in October 2026, also says that Agent SDK usage, `claude -p` and third-party app usage still draw from your subscription limits when you are signed in with your plan. This is a reversal from earlier in 2026: OpenCode’s v1 provider docs still say that plugins for using Claude Pro or Max in OpenCode exist, that Anthropic explicitly prohibits this, and that OpenCode has not bundled them since version 1.3.0.

**Ordinary, individual use only**

Anthropic’s advertised Pro, Max and Ultra limits assume ordinary, individual use of Claude Code and the Agent SDK, and Anthropic says it may enforce its credential rules without prior notice. Do not put a personal Claude subscription behind an OpenCode server that a team shares. Use API keys, Team or Enterprise seats, or a cloud provider for that.

## When is an API key or OpenCode Console the better choice?

Pay per token when the work runs on a server, in CI, for a team or in a remote workspace. The Claude Agent provider needs Claude Code installed and signed in on the same machine as the OpenCode server, so it is not available in hosted OpenCode or remote workspaces. With an API key, OpenCode calls Anthropic directly. You can connect the key with `/connect`, or hand it to the background server as an environment variable:

Python

```
# Anthropic API key for the shared background server
opencode service set env ANTHROPIC_API_KEY sk-ant-...
opencode auth list

# Or for a single run with a private server
ANTHROPIC_API_KEY=sk-ant-... opencode --standalone
```

OpenCode Console resells the same models on prepaid credit, which is convenient if you want one OpenCode bill across several vendors. As of October 2026 its prices match Anthropic’s for input and output tokens. The one difference in the table is the Sonnet 5.5 cache read, and in a long coding session most input tokens are cache reads.

Per 1M tokens, October 2026

Anthropic API: input / output

Anthropic cache read

Console: input / output

Console cache read

Claude Opus 5.5

$4.00 / $20.00

$0.20

$4.00 / $20.00

$0.20

Claude Sonnet 5.5

$2.00 / $10.00

$0.10

$2.00 / $10.00

$0.20

Claude Haiku 5.5, up to 100K

$0.10 / $0.50

$0.01

$0.10 / $0.50

$0.01

Five-minute cache writes cost 1.25 times the input price at both: $5.00 for Opus 5.5, $2.50 for Sonnet 5.5 and $0.125 for Haiku 5.5. OpenCode places prompt-cache breakpoints on Anthropic routes automatically. Only when Claude sits behind an OpenAI-compatible proxy such as LiteLLM do you set `compatibility.cacheFormat` to `"anthropic"` on those models, because OpenCode cannot tell from the proxy that they need Anthropic-style breakpoints. My [Claude pricing guide](https://balazscsorba.com/blog/claude-plans-pricing-usage-limits) compares plan limits with API costs in more detail.

## Can you use Claude through Copilot, OpenRouter, Bedrock or Vertex?

Yes, all four work, and they make sense when you already pay for that service. **GitHub Copilot** connects through GitHub’s device login, and the account needs Copilot Chat access. GitHub lists Claude Haiku 4.5 and 5.5, Sonnet 4.6, 5 and 5.5, Opus 4.8, 5 and 5.5, and Fable 5 and 5.1 as generally available in Copilot, but Copilot Free and Student users only get models through auto model selection. OpenCode fetches the account’s current model list after login.

**OpenRouter** takes an `OPENROUTER_API_KEY` or a connected account, and models use the full OpenRouter ID after the prefix, such as `openrouter/anthropic/claude-sonnet-5.5`. My model list also showed moving aliases such as `openrouter/~anthropic/claude-sonnet-latest`. **Amazon Bedrock** uses the AWS default credential chain, and a named AWS profile is the simplest durable setup. **Google Vertex** uses Application Default Credentials and needs a project before its models appear. The provider spec notes that Bedrock’s regional model IDs, such as `us.anthropic.claude-opus-5-5`, are priced 10% higher than Anthropic’s list prices.

**OpenCode Go** is the cheapest way in, but it only covers Claude Haiku 5.5 among the Claude models. The Go plan costs $10 a month, and OpenCode estimates 3,850 Haiku 5.5 requests per five hours on it, assuming 1,100 input, 55,000 cached and 240 output tokens per request. That suits a subagent or a cheap side model, not a main coding agent. My [Haiku 5.5 guide](https://balazscsorba.com/blog/claude-haiku-5-5) covers which jobs it handles well.

## What did a small test run show?

Both subscription routes fixed the same small bug in about five seconds, and the Claude Agent route used OpenCode’s tools as the spec describes. I ran one task with OpenCode 2.2.4 and Claude Code 2.1.314: a two-line Python file whose `add()` subtracted, with the prompt to fix it and describe the change in one sentence. Both runs used Haiku 5.5 with `opencode run --format json`, once through `claude-agent/haiku` on my Claude plan and once through `opencode-go/claude-haiku-5-5`.

Route

Steps

Cache write

Cache read

Output

At list prices

`claude-agent/haiku`

read, edit, answer

16,901

52,057

198

≈ $0.003

`opencode-go/claude-haiku-5-5`

read, edit, answer

20,843

41,357

182

≈ $0.003

OpenCode showed a cost of $0 for both runs, because each plan covers the usage. The list-price column is my own calculation at Haiku 5.5 prices, assuming five-minute cache writes. The prompts were similar in size: about 22,900 tokens through Claude Agent, with Claude Code’s system prompt, and about 20,700 through Go, with OpenCode’s own. The first Claude Agent step already read 6,226 tokens from cache in a fresh session, most likely the part of Claude Code’s system prompt still cached from my earlier Claude Code use. Both transcripts show the `read` and `edit` tool calls coming from OpenCode.

Two practical notes from the test. My OpenCode Console account had no credit, and that route failed at once with a 402 “Insufficient account funds” error, since Console is prepaid. And `opencode run` called from a script without a terminal waited for input until I closed standard input with `< /dev/null`; with that, every run finished normally.

## How do you set models and effort for Claude in OpenCode?

Set a default model in `opencode.jsonc` and give individual agents their own model with an optional `#variant`. A common split is a strong model for planning, a mid-size model for building and a small model for search. OpenCode’s built-in agents are `build` and `plan` as primary agents and `general` and `explore` as subagents:

JSON

```
{
  "$schema": "https://opencode.ai/config.json",
  "model": "claude-agent/sonnet",
  "agents": {
    "plan": { "model": "claude-agent/opus#high" },
    "explore": { "model": "claude-agent/haiku" }
  }
}
```

`#high` selects an effort variant. Variant names come from the model’s catalog metadata, and an unknown variant fails with a model-resolution error, so check `/models` before you commit a config. A subagent without its own model inherits the parent session’s model. With the Anthropic provider the same config uses IDs such as `anthropic/claude-opus-5-5#high`. On the Claude Agent provider, temperature, top-p, top-k, seed and stop sequences are not supported, and setting `CLAUDE_CODE_EFFORT_LEVEL` in your shell has no effect, because the provider clears it so that the effort chosen in OpenCode applies.

## What does not work with Claude Agent in OpenCode?

The provider gives you Claude’s models inside OpenCode, not Claude Code’s product features. The OpenCode docs and the design spec list these gaps:

-   No hosted OpenCode and no remote workspaces, because Claude Code must run on the same machine as the OpenCode server.
-   Claude Code’s system prompt replaces OpenCode’s built-in agent prompts; custom agent prompts still apply.
-   Plugin `http.request` and `http.response` hooks do not run, because Claude Code makes the API calls.
-   Claude Code features without an OpenCode equivalent are missing: `/usage` and the options shown at a plan limit, `/loop`, auto mode, agent teams, cloud sessions and `/teleport`, computer use, sandboxed Bash and bundled skills such as `/simplify`. OpenCode’s own `/usage` shows Console usage instead.
-   Tool calls run one at a time, as described above.

If you rely on those Claude Code features every day, run Claude Code itself; my [Claude Code review](https://balazscsorba.com/blog/claude-code) covers it. The provider is for people who prefer OpenCode’s interface, its multi-model sessions and its permission rules, but want their Claude plan behind them.

## Which route should you choose?

Pick the route that matches who uses OpenCode and where it runs:

1.  **Your own machine and an existing Claude Pro, Max or Ultra plan:** the Claude Agent provider. It uses limits you already pay for and keeps OpenCode’s workflow.
2.  **A team, CI, a server or a remote workspace:** an Anthropic API key, or Bedrock or Vertex if your company already runs there. Choose OpenCode Console if you want one prepaid OpenCode bill across vendors.
3.  **An existing Copilot seat:** the GitHub Copilot provider, within your Copilot plan’s models and limits.
4.  **A cheap small model on the side:** OpenCode Go for Haiku 5.5, for example as the `explore` subagent.
5.  **Routing and fallbacks across vendors:** OpenRouter, if you already use it.

Whatever you pick, keep your project instructions in AGENTS.md rather than CLAUDE.md, since that is what OpenCode passes to every model, including Claude through the Claude Agent provider. The [decision matrix for AGENTS.md, skills, MCP and CLIs](https://balazscsorba.com/blog/agents-md-skills-mcp-cli-decision-matrix) helps with that split. If you are setting up coding agents for a team and need the cost and data-protection side sorted out, that is part of my [AI engineering work](https://balazscsorba.com/expertise/ai-engineer).

## Sources

1.  [OpenCode v2.2.3 release notes (October 30, 2026)](https://github.com/anomalyco/opencode/releases/tag/v2.2.3)
2.  [OpenCode pull request #58782: add Claude Agent provider](https://github.com/anomalyco/opencode/pull/58782)
3.  [Claude Agent provider design spec](https://github.com/Tarquinen/opencode/blob/claude-agent-provider/specs/v2/claude-agent-provider.md)
4.  [OpenCode docs: Providers](https://opencode.ai/v2/docs/providers/)
5.  [OpenCode docs: Models](https://opencode.ai/v2/docs/models/)
6.  [OpenCode docs (v1): Providers, note on Claude Pro/Max plugins](https://opencode.ai/docs/providers/)
7.  [OpenCode Console: models and pricing](https://opencode.ai/v2/docs/console/models/)
8.  [OpenCode Go: plans and usage limits](https://opencode.ai/v2/docs/console/go/)
9.  [Claude Code docs: Legal and compliance](https://code.claude.com/docs/en/legal-and-compliance)
10.  [Claude Help Center: Use the Claude Agent SDK with your Claude plan](https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan)
11.  [Claude Platform docs: Pricing](https://platform.claude.com/docs/en/about-claude/pricing)
12.  [GitHub Docs: Supported AI models in GitHub Copilot](https://docs.github.com/en/copilot/reference/ai-models/supported-models)

## Frequently asked questions

Can I use my Claude Pro or Max subscription in OpenCode?

Yes, through the Claude Agent provider that shipped in OpenCode 2.2.3. It runs your installed Claude Code program, signed in with claude auth login, through Anthropic’s Claude Agent SDK, and usage draws from your plan limits. Do not use plugins that log in to OpenCode with your Claude.ai account directly; Anthropic’s terms prohibit that.

Does Claude Code’s CLAUDE.md or its hooks still apply in OpenCode?

No. The provider starts Claude Code with your ~/.claude settings, CLAUDE.md files, hooks, MCP servers and skills turned off. OpenCode passes its own AGENTS.md files, skills and MCP instructions instead, and Claude uses OpenCode’s tools.

Why does OpenCode show a cost of $0 for Claude Agent?

Because a subscription login covers the usage. If Claude Code is signed in with an API key or a cloud account, OpenCode shows that route’s per-token price instead. A custom base URL, such as a company gateway, also shows $0, since the gateway bills separately.

Can I use Claude Agent in a remote workspace or on a server for my team?

Not in hosted OpenCode or remote workspaces: Claude Code must be installed on the same machine as the OpenCode server. For shared servers and teams, use an Anthropic API key, OpenCode Console or a cloud provider, because Anthropic’s plan limits assume ordinary, individual use.

Is Claude cheaper through OpenCode Console than through the Anthropic API?

Not cheaper. As of October 2026 Console charges the same input and output prices as Anthropic for Opus 5.5, Sonnet 5.5 and Haiku 5.5. For Sonnet 5.5 cache reads, Console charges $0.20 per million tokens, where Anthropic charges $0.10.

Written by Balázs Csorba

Senior fullstack & AI engineer in Styria, Austria – 10+ years of Vue, Nuxt, Node.js and PHP, now building tooling for AI agents.

[AI engineering & MCP servers →](https://balazscsorba.com/expertise/ai-engineer)[About me →](https://balazscsorba.com/about)

## More articles

-   [The agent loop, explained: how coding agents run, and how to make them stop](https://balazscsorba.com/blog/agent-loop-explained)
-   [Claude Code Review is generally available: how the multi-agent review works and costs](https://balazscsorba.com/blog/claude-code-review)
-   [Claude skills: how to write a SKILL.md that loads at the right moment](https://balazscsorba.com/blog/claude-skills-guide)
-   [Migrating a legacy codebase with coding agents: a strangler fig playbook](https://balazscsorba.com/blog/coding-agents-legacy-codebase-migration)

## Sounds like what you need?

Tell me about your project or role – I’d love to hear from you.

[Get in touch](mailto:contact@balazscsorba.com) [Connect on LinkedIn](https://www.linkedin.com/in/balazs-csorba)
