Claude Code in Russia: when an aggregator key works

9 min read

A developer copies a key from a Russian aggregator, pastes it into the terminal, and Claude Code accepts it. Authorization goes through, the interface is ready to work. But on the first attempt to ask a question or read a local file, the agent throws an error. Hours of debugging follow. You check the balance, reissue tokens, switch networks. The problem looks like a network one, but in fact the key physically can't work. The cause isn't a network failure but the format the CLI agent expects.

The request goes out, a response comes back, but the data structure doesn't match.

How a gateway works for Anthropic's CLI agent

Claude Code is Anthropic's official CLI agent, built to work with a codebase straight from the console. It's not a web chat and not an editor plugin. It can read files, edit source code and run shell commands on its own.

To talk to servers, the agent uses a strictly defined gateway protocol. According to the official documentation as of August 28, 2026, Claude Code accepts exactly three request formats. Each one is switched on by its own environment variable.

The first format is Anthropic Messages. It's enabled with the ANTHROPIC_BASE_URL variable and calls the /v1/messages endpoint. Optionally, the gateway uses /v1/messages/count_tokens to count the context size before sending.

The second format is Amazon Bedrock InvokeModel. This path needs the ANTHROPIC_BEDROCK_BASE_URL variable and the CLAUDE_CODE_USE_BEDROCK=1 flag. Requests go to /model/{model}/invoke.

The third format is Google Cloud Agent Platform. It works through the ANTHROPIC_VERTEX_BASE_URL variable and the CLAUDE_CODE_USE_VERTEX=1 flag, using the :rawPredict endpoint. The last two formats exist for corporate infrastructure. They're for teams whose traffic is tightly bound to the Amazon and Google clouds.

Strict requirements for streaming and pings

The protocol puts strict technical constraints on the server in the middle. Responses must be streamed, as a continuous flow of tokens. If an aggregator's gateway buffers the response and tries to return it in one piece at the end of generation, the Claude Code client simply hangs.

On top of that, the agent tracks every byte it receives. It forcibly drops the connection after 300 seconds of silence. In practice this means the provider has to pass keep-alive pings through. When the model is "thinking" over a large chunk of code or analyzing a directory structure, long pauses happen. A session without regular pings will drop on timeout.

The anthropic-version and anthropic-beta headers must be passed through by the server unchanged. Routing requests to other vendors' models through this gateway isn't officially supported. To fill the list of available models, the agent uses an optional GET /v1/models?limit=1000 request. If the server doesn't serve it, nothing breaks: the model list simply falls back to the built-in one.

Why an aggregator key doesn't work in the terminal

The main reason Claude Code won't connect to the vast majority of Russian services comes down to one fact. The list of supported formats doesn't include the OpenAI-compatible /v1/chat/completions endpoint.

That format is the de facto standard on the aggregator market. Most tools understand the OpenAI structure. Anthropic's CLI agent goes its own way. It doesn't check whether the required endpoint exists when you enter the key. The agent fails not at authorization but at the moment it sends its first real request. It tries to send an Anthropic data structure to a server that expects an OpenAI one, or knocks on a path that doesn't exist and gets an error.

This is the key sign that lets you check any service in ten seconds. No need to hunt for reviews or test keys blindly. Just open the provider's documentation and see whether it has a /v1/messages endpoint. If the service only exposes /v1/chat/completions, Claude Code won't work through it.

Official pricing and token costs

To see why developers try to set this tool up at all, let's look at Anthropic's official pricing. Data as of August 28, 2026.

Access to Claude Code depends on your subscription tier. It isn't included in the Free plan. People with a Pro subscription at $20 a month, or $17 a month billed annually, don't need a third-party gateway for the agent. They work with the official API.

For teams there's the Max plan. Its limits are 5 or 20 times higher than Pro's. The price starts at $100 a month; exact figures aren't published on the pricing page. The Team plan costs $25 per seat per month, and a premium seat is $125. The Enterprise self-serve plan charges $20 per seat plus actual token usage.

If you use the API directly, the official prices per million tokens look like this. Claude Opus 5 costs $5 for input and $25 for output. Claude Sonnet 5 runs $2 per million input tokens and $10 for output. Claude Haiku 4.5 is $1 for input and $5 for output. Claude Fable 5 charges $10 for input and $50 for output.

ModelInput (per 1M tokens)Output (per 1M tokens)
Claude Opus 5$5$25
Claude Sonnet 5$2$10
Claude Haiku 4.5$1$5
Claude Fable 5$10$50

Claude Code via altrouter

Since October 27, 2026, Claude Code connects to altrouter: we have an Anthropic-compatible /v1/messages and /v1/messages/count_tokens, and responses stream with keep-alive pings. You need three environment variables:

Shell
export ANTHROPIC_BASE_URL=https://api.altrouter.ai
export ANTHROPIC_AUTH_TOKEN=ar-...
export ANTHROPIC_MODEL=claude-sonnet-5.5
claude

The ar-... key comes from your dashboard; the model can be any from the catalog, for example claude-sonnet-5.5 or claude-opus-5.5. Without ANTHROPIC_MODEL, Claude Code sends its own default ID with a date, like claude-sonnet-4-5-20250929: we drop the date, and the request goes to the same model if it's in the catalog.

What you won't get through us: Anthropic's built-in server tools such as web search - they run on Anthropic's servers, not at the gateway.

Our prices for Claude models are below the official ones - see the table below, data as of August 28, 2026.

Claude Sonnet 5 costs $1.6898 per million input tokens and $8.4987 for output with us. That's a 15% discount, calculated from the vendor's official price. Claude Sonnet 4.6 goes for $2.6843 for input and $13.50045 for output - a 10% discount.

Claude Opus 4.8 costs $4.50 for input and $22.50 for output, a 10% discount. Claude Haiku 4.5 comes to $0.771925 for input and $3.999975 for output, 20% below Anthropic's price.

ModelOur inputOur outputDiscount vs official
Claude Sonnet 5$1.6898$8.498715%
Claude Sonnet 4.6$2.6843$13.5004510%
Claude Opus 4.8$4.50$22.5010%
Claude Haiku 4.5$0.771925$3.99997520%

How to run Claude models in a code editor

If your provider doesn't support the Anthropic format, you won't be able to run Claude Code through it. Then there are two paths: move to a gateway with /v1/messages, or switch tools.

  • Find out which format your service exposes. Look in its documentation for the base URL and the list of endpoints.
  • If you only see /v1/chat/completions, drop the idea of using the original Claude Code.
  • Pick any IDE extension that lets you set base_url by hand - the address requests go to - in the OpenAI format. Options are covered in our AI for coding guide.
  • In the tool's settings, enter your provider's address and paste the key. Claude models will work through that interface.

FAQ

How do I connect Claude Code through the OpenAI API?

You can't. Claude Code's official gateway support doesn't include the OpenAI-compatible /v1/chat/completions endpoint. It works only through the Anthropic Messages, Amazon Bedrock or Google Cloud Vertex formats. Through altrouter, Claude Code connects using the Anthropic Messages format, with a model ID from the catalog.

Does Claude Code work with altrouter?

Yes, since October 27, 2026. altrouter has an Anthropic-compatible /v1/messages: set ANTHROPIC_BASE_URL=https://api.altrouter.ai, put your key in ANTHROPIC_AUTH_TOKEN and the model in ANTHROPIC_MODEL. Requests are charged to the same balance and at the same prices as through the OpenAI-compatible API - how keys work.

Why does Claude Code accept my key but fail on the first request?

The agent doesn't check whether the required endpoint exists when you enter the key. Authorization passes locally. On the first attempt to send a task, the CLI agent calls /v1/messages. If the service only offers the OpenAI format, the request returns an error - more on the two formats in our Claude API guide.

Is Claude Code included in the free Claude plan?

No. As of August 28, 2026, Claude Code isn't available on the Free plan. To use it you need at least a Pro subscription at $20 a month, or a business plan. The alternative is paying per token through the API - see Claude models and prices.

What endpoint does Claude Code need?

For a third-party service to connect through ANTHROPIC_BASE_URL, the provider must support the /v1/messages route. The server must also handle streaming and keep-alive pings correctly.

Don't spend hours debugging keys if the terminal throws an error on the first request. Check your API provider's documentation for the right route. If it isn't there, use Claude models through tools that support universal formats.

Learn more about available models and connection formats at altrouter.ai. The full list of supported models and current prices is in the model catalog.