{"slug":"claude-code-on-cloudflare-ai-gateway","verification":{"valid":true,"entries":30,"head":"c38b46e4fab04d7509d0d8205c897c62a6627826e8741edf6f22ddb7bd5d24c1"},"energy":{"passes":30,"tokens_in":0,"tokens_out":0,"tokens_total":0,"cost_usd":0,"models":{"Opus 5 (Claude Code)":30},"head":"c38b46e4fab04d7509d0d8205c897c62a6627826e8741edf6f22ddb7bd5d24c1"},"provenance":[{"ts":"2026-07-26T01:21:34.588Z","model":"Opus 5 (Claude Code)","action":"sources","prompt":"","input":"claude-code-on-cloudflare-ai-gateway","response":"29 source(s) added","tokens_in":0,"tokens_out":0,"cost":0,"prev":"genesis","hash":"51b355de3e7c82a07674c132e48051e310f7dffdf31be2edf26562dbefc5ab32"},{"ts":"2026-07-26T01:22:52.983Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c1","response":"Claude Code posts inference to /v1/messages?beta=true with two distinct model slots: a main call carrying the full tool list at max_tokens 32000, and a tool-free background call at max_tokens 1024.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"51b355de3e7c82a07674c132e48051e310f7dffdf31be2edf26562dbefc5ab32","hash":"aac44d3272b469a6c02717ac06720b37a90de44d7ac9f2b4e615161059f9f712"},{"ts":"2026-07-26T01:22:53.494Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c2","response":"A gateway must stream responses and must forward the anthropic-beta header verbatim; /v1/messages/count_tokens is optional and its absence makes the client estimate context locally.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"aac44d3272b469a6c02717ac06720b37a90de44d7ac9f2b4e615161059f9f712","hash":"0561509e7656536f84880b9601a1b5ab4a741a8998384113771a945256b9736a"},{"ts":"2026-07-26T01:22:54.090Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c3","response":"Cloudflare documents Claude Code against its AI Gateway Anthropic endpoint, which exposes the same /v1/messages API the client expects.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"0561509e7656536f84880b9601a1b5ab4a741a8998384113771a945256b9736a","hash":"2ce114a3dd8731cd334108d014bee48b531fb95d771658dd87ab0d0735a6937a"},{"ts":"2026-07-26T01:22:54.654Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c4","response":"The gateway's Anthropic provider is a reverse proxy to api.anthropic.com and cannot route a /v1/messages request to a non-Anthropic model; the account REST endpoint /ai/v1/messages excludes Workers AI @cf/ models by documentation.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"2ce114a3dd8731cd334108d014bee48b531fb95d771658dd87ab0d0735a6937a","hash":"468cde43126a170102e94372d368630da967deffc1b4bc4c50cd5c3ca5700daf"},{"ts":"2026-07-26T01:22:55.214Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c5","response":"Kimi, GLM, Grok and DeepSeek are catalogued on Cloudflare as Chat Completions only, so Claude Code cannot reach them without format translation.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"468cde43126a170102e94372d368630da967deffc1b4bc4c50cd5c3ca5700daf","hash":"fe45f3ac9add9e5b32c628c1123bbe3fd5936c65416cfa1099018ac6007eebbe"},{"ts":"2026-07-26T01:22:55.763Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c6","response":"Cloudflare's /ai/v1/messages returns a true Anthropic envelope for anthropic/* models but answered minimax/m3 with an OpenAI chat.completion body, so accepting the request is not the same as answering in the schema.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"fe45f3ac9add9e5b32c628c1123bbe3fd5936c65416cfa1099018ac6007eebbe","hash":"086b4d84c0767cee13642be2000f771339b17634373fda4cd91ba689d27963b2"},{"ts":"2026-07-26T01:22:56.363Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c7","response":"Measured through one AI Gateway: a Kimi K2.7 Code turn cost $0.01089448 at 21,928 input tokens with MCP disabled, against $0.02852109 at 149,187 input tokens with one MCP server attached.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"086b4d84c0767cee13642be2000f771339b17634373fda4cd91ba689d27963b2","hash":"59858fad913beedf4ca973f5a4dc13221648001443d240734ca57070609c3d9f"},{"ts":"2026-07-26T01:22:56.935Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c8","response":"Unified Billing is refused on a gateway with authentication off, returning HTTP 402 for catalogue models while Workers AI @cf/ models continue to work.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"59858fad913beedf4ca973f5a4dc13221648001443d240734ca57070609c3d9f","hash":"5ca82bb36ddcc06ef205b436702d128ed0107ab7ea2e73579fc619fd24517f4a"},{"ts":"2026-07-26T01:22:57.419Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c9","response":"Disabling one MCP server cut input from 149,443 tokens to 21,928 and raised cached input from 64 tokens to 13,312 once the per-request attribution block was stripped.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"5ca82bb36ddcc06ef205b436702d128ed0107ab7ea2e73579fc619fd24517f4a","hash":"520b78f2b6d95c2513ee9fea1f8382257e3b462e5ef87fb3474f6289e6fdfb97"},{"ts":"2026-07-26T01:22:57.895Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c10","response":"No existing Anthropic-to-OpenAI shim targets Cloudflare Workers AI, and each of the four that run as Cloudflare Workers fails on a contract element Claude Code depends on.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"520b78f2b6d95c2513ee9fea1f8382257e3b462e5ef87fb3474f6289e6fdfb97","hash":"4d883c646c6f203f4206249115a8ed5ed4f4084e0be6b254f9f82f7212f03124"},{"ts":"2026-07-26T01:22:58.388Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c11","response":"Rewriting tool_use identifiers in translation can break upstream tool parsing and make Claude Code end its turn mid-task with no error surfaced in the client.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"4d883c646c6f203f4206249115a8ed5ed4f4084e0be6b254f9f82f7212f03124","hash":"d99054336b1b070cafa6ad0d2ab5853abaa57890bdbf40f6ab6683562b1fd3d3"},{"ts":"2026-07-26T01:22:59.084Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c12","response":"Claude Code prepends a per-request attribution line to the system prompt which Anthropic strips positionally, defeating prefix caching on every other provider until it is removed.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"d99054336b1b070cafa6ad0d2ab5853abaa57890bdbf40f6ab6683562b1fd3d3","hash":"d2bf9fa66c3b54e04b891410c4b01bf889e719f216e7d970286321fce62342df"},{"ts":"2026-07-26T01:22:59.623Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c13","response":"The desktop client validates model names against an Anthropic-shaped allowlist, so a gateway model id such as kimi-k2.7-code is rejected before any request is sent.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"d2bf9fa66c3b54e04b891410c4b01bf889e719f216e7d970286321fce62342df","hash":"f67aeed6278607f82ffd863e03398db14359874ba062cc8f378106e26683748d"},{"ts":"2026-07-26T01:23:00.242Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c14","response":"Unified Billing applies a 5% fee to purchased credits, passes provider inference pricing through without markup, and excludes Workers AI @cf/ models.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"f67aeed6278607f82ffd863e03398db14359874ba062cc8f378106e26683748d","hash":"cb8e88c36563eb4e1fab3506c1704c33062616771a440cbbd4f6ed385259f505"},{"ts":"2026-07-26T01:23:00.764Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c15","response":"AI Gateway token permissions cannot be scoped to a single gateway, so any token with Run permission can send requests through every gateway on the account, including gateways holding stored provider keys.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"cb8e88c36563eb4e1fab3506c1704c33062616771a440cbbd4f6ed385259f505","hash":"c13f1740a215f03dafc228a4db6b210ff7fc5f0cf81428526b9ef17fabd01732"},{"ts":"2026-07-26T01:23:01.263Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c16","response":"Anthropic states it does not endorse, maintain or audit third-party gateway products and does not support routing Claude Code to non-Claude models through any gateway.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"c13f1740a215f03dafc228a4db6b210ff7fc5f0cf81428526b9ef17fabd01732","hash":"1de5aaa6a6b959b741ad95fffa02b69d04972fbb5939df7f101e31e732513c19"},{"ts":"2026-07-26T01:23:02.021Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c17","response":"Claude Code sends thinking: {type: adaptive} to models behind a custom base URL, producing 400s, empty responses or hangs, and its subagent and structured-output calls omit the field entirely, failing against endpoints that require it.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"1de5aaa6a6b959b741ad95fffa02b69d04972fbb5939df7f101e31e732513c19","hash":"003479e8980c9e345a6e0fa87e8be99fead24c94090b53f5e01e970219694d3b"},{"ts":"2026-07-26T01:23:02.605Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c18","response":"Moonshot, Z.ai and DeepSeek each publish an Anthropic-format base URL with their own Claude Code instructions, giving a working route with no proxy and no Cloudflare billing.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"003479e8980c9e345a6e0fa87e8be99fead24c94090b53f5e01e970219694d3b","hash":"a3e65050691c2ee99f882000cbbc7730e7c271ce9d646006d039eae7a30e20e0"},{"ts":"2026-07-26T01:23:03.113Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c19","response":"OpenRouter serves Claude Code's native protocol directly at https://openrouter.ai/api with no local proxy, and is also a first-class AI Gateway provider.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"a3e65050691c2ee99f882000cbbc7730e7c271ce9d646006d039eae7a30e20e0","hash":"5de7c2c5b1463360fb227ee6b58119687b066634286557fdf3728932fb6c3e8f"},{"ts":"2026-07-26T01:23:03.695Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c20","response":"Cloudflare custom providers proxy any HTTPS base URL under custom-<slug>, so a vendor's own Anthropic endpoint can sit behind the gateway with observability and caching but without Unified Billing.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"5de7c2c5b1463360fb227ee6b58119687b066634286557fdf3728932fb6c3e8f","hash":"6acc7f2040a5dedb2ddbe4939272efea7311b0a4159594479c007a396f6bf019"},{"ts":"2026-07-26T01:23:04.253Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c21","response":"llama.cpp, vLLM, Ollama and LM Studio all serve /v1/messages natively as of early 2026, so local models need no translation proxy.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"6acc7f2040a5dedb2ddbe4939272efea7311b0a4159594479c007a396f6bf019","hash":"e22d708e739adeac7be78f825ac4ef9c16b244b963213d3452c882cc277d85dd"},{"ts":"2026-07-26T01:23:04.753Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c22","response":"On identical independent harnesses the open models sit one tier behind Claude: SWE-bench Verified 76.8 Opus 4.5, 72.8 GLM-5, 70.8 Kimi K2.5 on mini-SWE-agent 2.0.0; Terminal-Bench 2.1 with Claude Code 83.8 Fable 5 against 58.7 GLM-5.1.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"e22d708e739adeac7be78f825ac4ef9c16b244b963213d3452c882cc277d85dd","hash":"47e8c3df272f9dd09060264cd9d1b7c6887d88ccde3e658bf92befdc33837858"},{"ts":"2026-07-26T01:23:05.277Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c23","response":"Every vendor-reported benchmark score with an independent counterpart is higher than the independent measurement, by 4 to 13 points, without exception.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"47e8c3df272f9dd09060264cd9d1b7c6887d88ccde3e658bf92befdc33837858","hash":"65cd012407d8bd5ec10822be2d9c5c937b61910b6b2dd8d3b38c6f128f9c7839"},{"ts":"2026-07-26T01:39:38.474Z","model":"Opus 5 (Claude Code)","action":"sources","prompt":"","input":"claude-code-on-cloudflare-ai-gateway","response":"3 source(s) added","tokens_in":0,"tokens_out":0,"cost":0,"prev":"65cd012407d8bd5ec10822be2d9c5c937b61910b6b2dd8d3b38c6f128f9c7839","hash":"102de840be34eeef7a33f2a58bc8ede4c7b90df64e1c4a8ee1637aec304d6128"},{"ts":"2026-07-26T01:39:59.464Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c24","response":"ENABLE_TOOL_SEARCH=true works behind a custom ANTHROPIC_BASE_URL gateway on claude-cli 2.1.165, reducing a request from 856 tool definitions to 9 plus a ToolSearch tool, against documentation stating tool search is unavailable in that configuration.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"102de840be34eeef7a33f2a58bc8ede4c7b90df64e1c4a8ee1637aec304d6128","hash":"67ceebc9589d754cd91503206832c0fab7e994ce635c7ec4c88fe02feef5c85e"},{"ts":"2026-07-26T01:39:59.995Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c25","response":"With the same MCP server attached, tool search cut measured input from 149,187 tokens and $0.02852109 per turn to 14,109 tokens and $0.00443075 — cheaper than running with no MCP server connected at all.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"67ceebc9589d754cd91503206832c0fab7e994ce635c7ec4c88fe02feef5c85e","hash":"d56f0aeb5f68624aa1b49fc6e8bd86925387ba81162b9cbe85284c9539e4b821"},{"ts":"2026-07-26T01:40:00.594Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c26","response":"A non-Claude model drives the deferred-tool loop: Kimi K2.7 Code called ToolSearch to locate an MCP tool it had not been shown, invoked it, and returned its payload verbatim.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"d56f0aeb5f68624aa1b49fc6e8bd86925387ba81162b9cbe85284c9539e4b821","hash":"433a5d1eca1f57b994bdb7ffdcbbc305630bf3d204b7f675527c93c8ef021ea2"},{"ts":"2026-07-26T01:40:01.325Z","model":"Opus 5 (Claude Code)","action":"claim","prompt":"","input":"claude-code-on-cloudflare-ai-gateway c27","response":"The translator is published as a single-file Cloudflare Worker under MIT with three secrets and a wire-capture tool, so the setup and every measurement in this article can be reproduced on another account.","tokens_in":0,"tokens_out":0,"cost":0,"prev":"433a5d1eca1f57b994bdb7ffdcbbc305630bf3d204b7f675527c93c8ef021ea2","hash":"faabf72cbad9b56b1ebd3c7965fc644e38aa33e1fc135439960c887db2f871b3"},{"ts":"2026-07-26T03:26:22.408Z","model":"Opus 5 (Claude Code)","action":"sources","prompt":"","input":"claude-code-on-cloudflare-ai-gateway","response":"5 source(s) added","tokens_in":0,"tokens_out":0,"cost":0,"prev":"faabf72cbad9b56b1ebd3c7965fc644e38aa33e1fc135439960c887db2f871b3","hash":"c38b46e4fab04d7509d0d8205c897c62a6627826e8741edf6f22ddb7bd5d24c1"}]}