English
Guides
Claude Models in OpenCode

Claude models in OpenCode: IDs, prices and setup

Already have an Anthropic API key? Use the native Anthropic connection below and set the model in opencode.json. Have a gateway key instead? Use the gateway’s endpoint and model ID. The tables cover native IDs and prices; the configuration examples show how to connect them.

Check the model and account first

The Anthropic model overview (opens in a new tab) lists these native Claude API IDs:

ModelClaude API ID
Claude Fable 5.1claude-fable-5-1
Claude Opus 5.5claude-opus-5-5
Claude Sonnet 5.5claude-sonnet-5-5
Claude Haiku 5.5claude-haiku-5-5
Claude Opus 5claude-opus-5
Claude Sonnet 5claude-sonnet-5
Claude Haiku 4.5claude-haiku-4-5-20251001

Opus 5.5, Sonnet 5.5 and Haiku 5.5 are the current models; Opus 5, Sonnet 5 and Haiku 4.5 remain available as legacy models. For Haiku 5.5's prompt-length pricing, benchmarks and Copilot or Bedrock setup, see the Claude Haiku 5.5 guide.

These are provider identifiers, not claims that every account or gateway can use them. Check account access and the Models API (opens in a new tab). Bedrock, Vertex AI and gateways can use different IDs; do not copy one provider's ID into another provider's configuration without checking its documentation.

For current rates, caching charges and other billing conditions, use Anthropic's pricing documentation (opens in a new tab).

Native Anthropic access

  1. Confirm that your Anthropic account has API access and the required billing setup. A Claude chat subscription does not automatically provide API credit.
  2. Start opencode and use /connect to select Anthropic and store its API key. Keep credentials out of committed project files.
  3. Use /models to select a model available in the provider catalog. OpenCode's provider catalog and your account access are separate checks.
  4. Send a small prompt without private project information. Confirm both the returned answer and the provider's usage record before increasing the workload.

The native Anthropic provider uses Anthropic's API. Do not configure the native API as an arbitrary OpenAI-compatible service. Follow the provider configuration guide.

If a model is absent, check your OpenCode version, provider catalog and account eligibility before adding overrides. Do not invent context or output limits to make a model appear supported.

Third-party gateway access

A gateway is a separate service with its own credentials, model inventory, billing and data terms. Its endpoint may expose Chat Completions, Responses or another protocol. The appropriate adapter depends on that protocol.

For a complete template with environment variables, provider ID, endpoint and model ID, see third-party API setup. Check your gateway's model list for availability.

Set a default Claude model

After connecting Anthropic, select a model through /models. To keep the same selection for this project, add its provider-qualified ID to opencode.json. For example, the native Anthropic ID shown above can be selected as:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-fable-5-1"
}

This does not create an API entitlement or store a key. The provider must already be connected, and the model must be available to that account. See model selection and variants before adding provider options or changing context settings.

Anthropic, Zen or another gateway?

RouteConfiguration namespaceWhere the usage is billed
Native Anthropicanthropic/<model-id>The connected Anthropic account
OpenCode Zenopencode/<model-id>Zen for its hosted models; provider billing when using the applicable bring-your-own-key option
Another gatewayYour configured provider ID and its advertised model IDThe gateway account under that service's terms

The Zen reference lists model IDs, endpoints, prices and team controls. Its catalog and rates should not be presented as native Anthropic pricing. For an OpenAI-compatible gateway, use the API setup template; for other protocols, follow the relevant provider configuration.

If you are deciding between OpenCode and Anthropic's client, read OpenCode vs Claude Code. Connecting a model through OpenCode does not transfer a Claude Code subscription allowance to an API account.

Choose a starting model

Use the same repository task to compare candidates from the table. For a refactor, include checks that behavior has stayed the same. For a test-writing task, confirm that the new test can detect the intended failure rather than merely pass on the current implementation.

You can assign different models to agents, but add complexity only after observing a need. Keep project rules and permissions consistent during the comparison so a configuration change does not masquerade as a model improvement.

Estimate cost from actual usage

These standard Claude API rates are in USD per million tokens. Cache durations are separate billing categories; gateway and cloud-provider prices can differ. See Anthropic's pricing reference (opens in a new tab) for other modifiers and service-specific charges.

ModelInputOutputCache read5-minute cache write1-hour cache write
Fable 5.1$10$50$0.25$12.50$20
Fable 5$10$50$1$12.50$20
Opus 5.5$4$20$0.20$5$8
Sonnet 5.5$2$10$0.10$2.50$4
Haiku 5.5 (prompt ≤ 100K tokens)$0.10$0.50$0.01$0.125$0.20
Haiku 5.5 (prompt > 100K tokens)$0.50$2.50$0.05$0.625$1
Opus 5$5$25$0.50$6.25$10
Sonnet 5$2$10$0.20$2.50$4
Haiku 4.5$1$5$0.10$1.25$2

Haiku 5.5 is the only current model priced by prompt length: a request whose total prompt, cache reads included, exceeds 100,000 tokens pays the higher row for all of its tokens.

Compute uncached input, cache reads, cache writes and output separately using the selected service's rates. A long conversation can resend context, and an agent can make several calls while reading files or correcting a test. A model's output price alone is not the total cost.

For an example with explicit quantities and rates, see Zen's cost calculation. For the broader distinction between free software, included allowances and metered inference, see free AI coding agents. The coding workflow guide helps keep the trial small enough to review.

Choose using a small evaluation

  • Choose a representative bug fix, a refactor and a test-writing task from a repository you can safely use.
  • Hold the starting commit, instructions, available tools and acceptance checks constant.
  • Record the exact provider, model ID, configuration, total cost, elapsed time and amount of manual correction.
  • Review the full diff as well as the test result. Passing tests do not prove that the change preserves every requirement.
  • Repeat trials when results vary. Keep the raw evidence before describing one model as faster or cheaper for your workload.

A lower price per token need not mean a lower cost per accepted change: retries, output volume, caching and tool calls affect the bill. Conversely, a higher-priced model need not improve a mechanical task. Decide from the results that matter to your project.

Separate model and client decisions

If changing the model does not solve the problem, review the client workflow itself. The coding-agent comparison separates editor, terminal, provider and billing choices. A successful API call establishes connectivity; acceptance tests and a reviewed diff establish whether a coding task succeeded.

Troubleshooting

A 401 or 403 response can indicate invalid credentials, account restrictions or policy. A model-not-found response can indicate the wrong provider ID, unavailable model or gateway alias. A 429 response requires checking the provider's limits and balance. Consult the connection checklist before reinstalling.

See the Fable setup guide for model-specific instructions.