Integration Guides

Using Claude Code from China: Three Access Routes and How to Pick One

Grace Whitmore

The actual problem, stated precisely

Claude Code is a command-line tool. It runs locally, reads your repository locally, and makes API calls to a model endpoint. Nothing about the CLI itself is region-locked.

The constraint sits one layer down, at the API account: Anthropic's first-party API is not offered in every market, and provisioning one requires a supported billing method and acceptance of terms that carry regional scope. For developers working from mainland China, that is where the process stops — not at installing the CLI.

Stating it this way matters, because it tells you what a solution has to do. You do not need to change the tool. You need a model endpoint that (a) speaks the protocol Claude Code expects, and (b) you can legitimately hold an account with.

There are three routes that satisfy both. They differ in cost, effort, and who carries the operational burden.

Route 1: A first-party Anthropic account

The direct path — an Anthropic account with API access, used from Claude Code with no intermediary.

What it requires: a billing method Anthropic accepts, and eligibility under their terms of service for the jurisdiction you are operating in. For teams with an overseas entity, an overseas corporate card, and a genuine business presence in a supported market, this is often already satisfied and is the cleanest option available.

What to verify before committing: eligibility is a terms question, not a technical one. Check Anthropic's current supported-regions and billing documentation rather than relying on what was true last quarter — this is the detail that changes most often, and the one where secondhand information ages worst.

Fits when: you have a supported entity and billing already. Then there is no reason to add a hop.

Route 2: A third-party endpoint that speaks the same protocol

Claude Code reads its endpoint from environment variables. Point those at any service implementing the Anthropic protocol and the CLI works unchanged — it is not aware of what is behind the URL.

This is why the category of protocol-compatible providers exists. You hold an account with a provider that can serve your market, that provider handles upstream model access, and your tooling is untouched.

What it requires: an account with the provider, and two environment variables. No code changes, no proxy to deploy, no infrastructure to run.

What to evaluate — and this is where the routes genuinely differ in quality:

  • Protocol fidelity. "OpenAI-compatible" and "Anthropic-compatible" are different surfaces. Claude Code speaks the Anthropic protocol; confirm the provider serves that one, not just an OpenAI-shaped endpoint. Providers frequently offer both, on different base URLs and sometimes with different key groups — picking the wrong pairing is the single most common setup failure.
  • Streaming and tool-use support. Claude Code depends on streaming responses and tool calls. A provider that handles simple completions correctly can still break on these. Test with a real agentic task, not a one-line "hello" completion.
  • Billing transparency. You want per-request accounting you can reconcile. Opaque credit systems make it impossible to tell whether a cost spike came from your usage pattern or from the provider's pricing.
  • Stability under load. A long Claude Code session is many sequential calls. A provider with intermittent timeouts is far more disruptive here than in a single-shot chat use case.

Fits when: you want to be working today, and you would rather not operate infrastructure.

If you take this route with ROIBest AI, the configuration itself is short — connecting Claude Code takes two environment variables, and that guide covers the two mistakes that account for most failed setups (using the wrong protocol group's key, and appending /v1 to the base URL when it should not be there).

Route 3: Self-hosted gateway or proxy

Run your own gateway that holds the upstream credentials and exposes an endpoint to your team.

What it requires: upstream API access that your gateway can legitimately use — meaning this route does not remove the account problem, it relocates it. You still need a valid upstream account somewhere; you have only added a layer you now operate.

What it buys you: centralized key custody, per-developer usage attribution, and internal policy enforcement. For an organization with many developers and a compliance requirement to log or restrict model traffic, that is a real benefit.

What it costs you: the gateway is on the critical path of every call, and you own its uptime. If you are weighing this seriously, the open-source gateway landscape and what self-hosting actually costs is the more detailed comparison.

Fits when: you are solving a team-governance problem, not an individual access problem. For a single developer this route is almost always more work than it returns.

Choosing between them

Your situation

Route

Overseas entity with accepted billing

First-party account

Individual developer or small team, want to start now

Protocol-compatible provider

Many developers, need central key custody and per-user attribution

Self-hosted gateway on top of a valid upstream account

The decision is mostly about who carries the operational burden, not about capability. All three end with the same CLI making the same calls.

Two things worth getting right regardless of route

Verify with a real task, not a smoke test. A trivial completion proves the endpoint answers. It does not prove streaming works, tool calls round-trip correctly, or long sessions stay stable. Run an actual multi-step task in a scratch repository before you depend on the setup.

Understand your cost drivers before optimizing. Agentic coding sessions consume far more input tokens than chat, because context is resent across turns. This makes prompt caching disproportionately valuable — and it means per-token headline rates can be misleading if caching behavior differs. What actually drives a Claude API bill covers where the money genuinely goes.

FAQ

Does Claude Code itself work from mainland China? The CLI is not the constraint — it runs locally like any other command-line tool. What you need to resolve is API account access and a reachable endpoint that speaks the Anthropic protocol.

Do I need to change my Claude Code configuration or install anything special? No. Claude Code reads its endpoint and credentials from environment variables. Any route above is a configuration change, not a different tool or a patched build.

Is an OpenAI-compatible endpoint enough for Claude Code? Not by itself. Claude Code speaks the Anthropic protocol. A provider may serve both surfaces, but you must use the Anthropic-protocol base URL and the matching key group. Mismatching these is the most common setup error.

How do I know a provider will hold up for real work? Test streaming, tool use, and a long multi-step session — in that order. Providers that pass a single completion test can still fail on the behaviors an agentic CLI depends on most.

Does routing through a third-party endpoint change what the model can do? It should not. What can differ is model version availability, context window limits, rate limits, and caching behavior. Verify those four specifically, since they affect both capability and cost.