In an article on Habr, the Just AI team explained how to connect Claude Code to an API gateway. Claude Code accesses three endpoints: POST /v1/messages — mandatory, nothing works without it; POST /v1/messages/count_tokens — optional, without it /context shows a character-based estimate instead of an exact count; GET /v1/models?limit=1000 — optional, without it /model shows only the built-in list. In Caila, the token-counting endpoint is implemented, so /context through the gateway shows exact numbers. Streaming must not be buffered: Claude Code reads the response as it arrives, and if the gateway assembles the entire response first, the agent will appear frozen. The client accounts for SSE events and terminates the stream after a long wait, so the gateway must send SSE pings during lengthy generation. Automatic model discovery is enabled via CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1. There are two limitations: the request must fit within a three-second timeout, and redirects are treated as an error — the client does not pass authorization data to another host. In addition, Claude Code filters the received list of models.
A gateway handles access, keys, limits, and spending. External provider keys remain with the gateway, while the developer is issued a separate platform key. You can cap the budget before the first launch and see spending by keys, models, and requests. This is especially relevant for Russian users: paying Anthropic directly requires a foreign card and a VPN, and as of June 27, 2026, OpenRouter no longer serves Russian accounts. The client-side part of the scenario also applies to other proxies — for example, your own LiteLLM installation or a corporate API gateway.
Over the past year and a half, Claude Code has gone from a niche hobby to one of the main tools of AI development. According to the JetBrains Developer Ecosystem Survey 2026 (a survey of over 15,000 developers, May–July 2026), 90% of respondents use AI coding agents at least once a week, and 68% daily. 39% use Claude Code, and 31% call it their primary tool. Anthropic analyzed about 400,000 Claude Code sessions over six months: the second-largest user group is business and finance, and among non-technical professions, the share of managers, salespeople, and lawyers is growing fastest.
Source: habr.com · post in Telegram