跳到主内容
@wquguru
精选88Cloudflare 博客(RSS)产品发布/更新

Cloudflare AI Gateway Auto Router 发布

Cut your AI spend with AI Gateway's Auto Router

原文
发到 X
推荐理由

Agent 开发者的省钱利器,通过自动路由避开“杀鸡用牛刀”,实测降本显著,建议接入链路压测对比效果。

From our conversations with companies at every stage of their AI adoption journey, we've seen some common patterns. First, there is an exploration period as you bring on every new tool, dole out API keys freely, and let the tokens flow. Then, you converge on the canonical tools for your organization for agentic coding, for non-technical workflows, for running and deploying agents. As companies formalize their AI adoption, they want to manage and oversee token spend for users, but budgets and rules only go so far. The best savings are the ones users never notice.

在与处于 AI 采用各个阶段的公司交流中,我们观察到了一些共同的模式。首先,在引入每种新工具、自由分发 API 密钥并让令牌(tokens)流动的过程中,会有一个探索期。随后,你们会收敛到适合组织的标准工具,用于代理式编码、非技术工作流以及运行和部署代理。随着公司正式规范其 AI 采用流程,他们希望管理和监督用户的令牌支出,但预算和规则的作用有限。最好的节省是那些用户从未察觉到的节省。

Today, we are releasing Cloudflare's Auto Router in public beta, available through AI Gateway. Set your model to cloudflare/auto and the Auto Router will automatically route each request to a model that is capable enough for the task, without requiring an end user to think about model selection. Our early results using the Auto Router internally through our OpenCode harness show a cost savings of up to 30% when compared to using only frontier models like OpenAI Sol and Anthropic Claude Opus.

今天,我们正式发布 Cloudflare Auto Router 的公开测试版,可通过 AI Gateway 使用。将模型设置为 cloudflare/auto,Auto Router 就会自动将每个请求路由到足以胜任该任务的模型,而无需最终用户考虑模型选择。我们在内部通过 OpenCode 框架使用 Auto Router 的早期结果显示,与仅使用前沿模型(如 OpenAI Sol 和 Anthropic Claude Opus)相比,成本节省了高达 30%。

Why we built this

我们构建此功能的原因

From our own experience tracking AI spend at Cloudflare, we’ve learned managing costs requires a multipronged approach. Previously, we talked about how to set budgets and limits around AI spend, and how to see who is spending across your organization by linking employees to their AI usage.

根据我们在 Cloudflare 追踪 AI 支出的经验,我们了解到管理成本需要多管齐下的方法。此前,我们曾讨论过如何围绕 AI 支出设定预算和限制,以及如何通过将员工与其 AI 使用情况关联起来,查看组织中谁在花费资金。

In many harnesses, including OpenCode, Claude Code, and Codex, individual users still select models manually. Of course, not all tasks are created equal, and often individuals end up using models that are overkill for their work. For example, you don't need Opus-level intelligence if you're looking to summarize an email or chat threads. However, you wouldn't want to block that model completely from your security engineering team.

在许多框架中,包括 OpenCode、Claude Code 和 Codex,单个用户仍然手动选择模型。当然,并非所有任务都同等重要,个人往往最终使用了超出其工作需求的模型。例如,如果你只是想要总结一封电子邮件或聊天线程,就不需要达到 Opus 级别的智能。然而,你也不希望完全从安全工程团队中屏蔽该模型。

Our goal is for AI Gateway to be the control plane for organizations deploying AI internally. Because every request from every user, agent, and tool already flows through it, AI Gateway is in a unique position to do more than observe and enforce. Budgets, spend limits, and identity-aware analytics give organizations visibility and guardrails, but they still rely on individuals to make cost-conscious choices request by request. The next step is for the gateway itself to make intelligent decisions on a user's behalf: sending each request to a model that is capable enough for the task. That way, organizations reduce spend automatically, while users keep access to the most capable models when their work actually needs them.

我们的目标是让 AI Gateway 成为组织内部部署 AI 的控制平面。由于来自每个用户、智能体和工具的请求都已流经它,AI Gateway 处于一个独特的地位,能够超越单纯的观察和强制执行。预算、支出限额和基于身份的分析为组织提供了可见性和护栏,但它们仍然依赖个人逐次做出注重成本的决策。下一步是让网关本身代表用户做出智能决策:将每个请求发送给具备完成任务能力的模型。这样,组织可以自动减少支出,同时用户在真正需要时仍能访问最强大的模型。

The results

结果

We use Auto Router internally at Cloudflare within our OpenCode deployment and within Cloudflare OS, our custom agent harness. In our internal usage, we’ve seen results comparable with frontier models for coding tasks.

我们在 Cloudflare 内部使用 Auto Router,应用于我们的 OpenCode 部署以及自定义智能体框架 Cloudflare OS。在内部使用中,我们看到的编码任务结果可与前沿模型相媲美。

Auto Router does best when used across a wide range of knowledge-work tasks, like those typically found in a large organization with work spanning both technical and non-technical teams. We evaluated cloudflare/auto against OpenAI’s GPT-6 Sol and Anthropic’s Claude Opus 5.5 on our internal general knowledge work benchmark. The benchmark uses simulated workspace tools and covers common day-to-day workflows across email, calendars, Slack, files, travel and finance. Each task requires the model to use these tools to produce a verifiable answer or complete an action.

Auto Router 在跨广泛知识工作任务时表现最佳,例如大型组织中通常存在的技术与非技术团队交织的工作。我们在内部通用知识工作基准测试中评估了 cloudflare/auto 与 OpenAI 的 GPT-6 Sol 及 Anthropic 的 Claude Opus 5.5。该基准测试使用模拟的工作区工具,涵盖电子邮件、日历、Slack、文件、差旅和财务方面的常见日常工作流程。每项任务都要求模型使用这些工具生成可验证的答案或完成某项操作。

ModelSuccessful TrialsSuccess RateTotal CostCost per success
cloudflare/auto252/29186.6% (+6.2/−6.9 pp)$2.10$0.0084
Anthropic Claude Opus 5.5281/29196.6% (+2.7/−3.8 pp)$5.91$0.0210
OpenAI GPT-6 Sol245/29184.2% (+6.5/−6.9 pp)$2.64$0.0108
模型成功试验次数成功率总成本每次成功成本
cloudflare/auto252/29186.6% (+6.2/-6.9 pp)$2.10$0.0084
Anthropic Claude Opus 5.5281/29196.6% (+2.7/-3.8 pp)$5.91$0.0210
OpenAI GPT-6 Sol245/29184.2% (+6.5/-6.9 pp)$2.64$0.0108

97 tasks with three samples per model per task. Parenthetical values show 95% confidence intervals estimated from 10,000 task-level bootstrap resamples, preserving all three repetitions within each task. “pp” indicates percentage points.

共 97 项任务,每项任务每个模型有 3 个样本。括号内的数值表示从 10,000 次任务级别的自助重采样中估计出的 95% 置信区间,保留了每项任务内的所有三次重复。“pp”表示百分点。

Our Auto Router delivered similar performance to other state-of-the-art daily-driver models, coming in at 80% the cost of Sol and 35% the cost of Opus. While that may initially seem surprising, one way to frame the problem a model router solves is through the “jagged frontier” across models. The ability to solve a problem often exists somewhere in this portfolio of models; the router’s job is to choose the right model for each task while balancing quality and price. Savings come from not paying frontier rates for non-frontier work, and they grow with how much of that work you have.

我们的 Auto Router 的性能与其他最先进的日常使用模型相当,其成本为 Sol 的 80% 和 Opus 的 35%。虽然这乍看之下可能令人惊讶,但理解模型路由器所解决问题的一种方式是通过跨模型的“锯齿状前沿”(jagged frontier)。解决某个问题的能力通常存在于这个模型组合中的某处;路由器的任务是在平衡质量和价格的同时,为每个任务选择合适的模型。节省成本来自于不为非前沿工作支付前沿费率,且随着此类工作量的增加,节省幅度也会增大。

Another insight is that lower token prices do not always produce lower-cost outcomes. A model that looks cheaper on paper may end up using disproportionately more tokens to solve a problem. A router should minimize predicted trajectory cost, not just load-balance by dollars per million tokens.

另一个见解是,较低的 token 价格并不总是带来较低的成本。一个在纸面上看起来更便宜的模型,最终可能会不成比例地消耗更多的 token 来解决问题。路由器应最小化预测轨迹成本,而不仅仅是按每百万美元的 token 数量进行负载均衡。

This is already useful today, but it’s only the beginning of what the Auto Router can learn from Cloudflare’s position in the inference path.

这在今天已经非常有用,但这仅仅是 Auto Router 能够从 Cloudflare 在推理路径中的位置学到的内容的开始。

How it works

工作原理

When you send a request to cloudflare/auto, AI Gateway first builds the pool of models that can actually serve it. It filters out models that do not support the request format or execution mode, and accounts for the credentials, billing configuration, access control policies, and spend limits attached to the gateway. It will also filter out unhealthy upstream providers or models during downtime and automatically bring them back into the pool after an outage.

当你向 cloudflare/auto 发送请求时,AI Gateway 首先构建能够实际处理该请求的模型池。它会过滤掉不支持请求格式或执行模式的模型,并考虑与网关关联的凭据、计费配置、访问控制策略以及支出限额。它还会在下线期间过滤掉不健康的上游提供商或模型,并在故障排除后自动将它们重新加入池中。

For the remaining candidates, the router looks at a compact view of the conversation. It considers the most recent messages, prioritizing the newest turns. The conversation is then sent to a multi-head classification model running on Workers AI and deployed on GPUs across our edge network. The classifier produces two sets of signals. First, it assigns probabilities across 14 task categories (like coding, planning, research, data analysis). It then rates the request across four dimensions on a scale from one to five: complexity, ambiguity, stakes, and dependence on earlier context.

对于剩余的候选模型,路由器会查看对话的紧凑视图。它考虑最近的消息,优先关注最新的交互轮次。然后,对话被发送到运行在 Workers AI 上的多头分类模型,该模型部署在我们边缘网络的 GPU 上。分类器生成两组信号。首先,它在 14 个任务类别(如编码、规划、研究、数据分析)上分配概率。接着,它在一到五的量级上从四个维度对请求进行评级:复杂性、歧义性、风险程度以及对早期上下文的依赖程度。

A separate scoring matrix combines those signals with model benchmark results to estimate how well each model fits the request. To calibrate the scoring matrix, we defined the preferred model for a set of example task and difficulty profiles, then adjusted the weights to produce those choices.

一个独立的评分矩阵将这些信号与模型基准测试结果相结合,以评估每个模型对请求的适配程度。为了校准评分矩阵,我们为一系列示例任务和难度配置文件定义了首选模型,然后调整权重以产生这些选择。

Finally, the router combines expected quality with each model's input and output token prices. On straightforward requests, price carries more weight, so a smaller model can win when it is capable enough. As difficulty rises, the cost penalty falls and stronger models have more room to win. In simplified terms, cloudflare/auto selects the model with the highest utility as defined by:

最后,路由器将预期质量与每个模型的输入和输出 token 价格相结合。对于简单的请求,价格权重更大,因此当较小模型的能力足够时,它可以胜出。随着难度增加,成本惩罚降低,更强的模型有更大的胜算空间。简而言之,cloudflare/auto 会选择效用最高的模型,其定义如下:

For long agentic sessions like debugging or coding, cost is less driven by the model’s list price than by the cost of cache reads, which grows with session length. Switching models throws the cache away and forces a new model to write the whole context again. This can be worth it, as a model with a cheaper cache-read and cache-write prices can pay back the rewrite quickly.

对于调试或编码等长期的智能体会话,成本受模型列表价格的驱动较小,而主要受缓存读取成本的驱动,后者随会话长度增长。切换模型会丢弃缓存,并迫使新模型重新写入整个上下文。这可能是值得的,因为具有更便宜缓存读取和写入成本的模型可以迅速收回重写带来的开销。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件