Cloudflare 统一 Workers AI 与 AI Gateway 访问及计费
AI Gateway, Workers AI - Workers AI and AI Gateway unify model access and billing
Cloudflare 用户注意:AI Gateway 与 Workers AI 统一后,可用同一套 API 和信用额度调用第三方模型,前沿模型速率限制提升至 50 RPM。建议开发者评估迁移至统一入口,以简化集成并利用统一计费。
Workers AI and AI Gateway now provide a unified path for accessing models and managing inference traffic. Use the same AI binding and REST API to call models hosted on Workers AI or by supported third-party providers, with AI Gateway providing observability, logging, caching, security, and billing controls.
Workers AI 和 AI Gateway 现在为访问模型和管理推理流量提供了统一路径。使用相同的 AI 绑定和 REST API 调用托管在 Workers AI 或受支持的第三方提供商上的模型,AI Gateway 提供可观测性、日志记录、缓存、安全性和计费控制。
Unified entrypoints and observability
统一入口和可观测性
The AI binding supports both Workers AI and third-party models through env.AI.run(). The REST API provides shared /ai/ endpoints with Cloudflare authentication across providers.
AI 绑定通过 env.AI.run() 支持 Workers AI 和第三方模型。REST API 提供跨提供商的共享 /ai/ 端点,并使用 Cloudflare 身份验证。
Route a Workers AI request through AI Gateway by specifying a gateway ID. Use default to automatically create a gateway on the first authenticated request, or specify an existing gateway to separate applications and workloads:
通过指定网关 ID,将 Workers AI 请求路由到 AI Gateway。使用 default 在首次经过身份验证的请求时自动创建网关,或指定现有网关以分离应用程序和工作负载:
const response = await env.AI.run(
"@cf/zai-org/glm-5.2",
{
messages: [{ role: "user", content: "What is the capital of France?" }],
},
{
gateway: { id: "default" },
},
);const response = await env.AI.run(
"@cf/zai-org/glm-5.2",
{
messages: [{ role: "user", content: "What is the capital of France?" }],
},
{
gateway: { id: "default" },
},
);const response = await env.AI.run(
"@cf/zai-org/glm-5.2",
{
messages: [{ role: "user", content: "What is the capital of France?" }],
},
{
gateway: { id: "default" },
},
);const response = await env.AI.run(
"@cf/zai-org/glm-5.2",
{
messages: [{ role: "user", content: "What is the capital of France?" }],
},
{
gateway: { id: "default" },
},
);Requests routed through AI Gateway can be logged and included in analytics for request volume, errors, latency, token usage, and costs. You can also configure controls such as caching, rate limiting, and request retries on the gateway.
通过 AI Gateway 路由的请求可以被记录并包含在请求量、错误、延迟、令牌使用和成本的分析中。您还可以在网关上配置缓存、速率限制和请求重试等控制。
Unified billing and higher rate limits
统一计费和更高的速率限制
You can now use prepaid AI Gateway credits to pay for Workers AI inference. This provides one credit balance for Workers AI and supported third-party model providers. To use credits for Workers AI, set the gateway's Workers AI billing setting to Unified billing. Workers AI requests routed through that gateway deduct from your credit balance in real time.
您现在可以使用预付费的 AI Gateway 积分来支付 Workers AI 推理费用。这为 Workers AI 和受支持的第三方模型提供商提供了一个积分余额。要使用积分支付 Workers AI,请将网关的 Workers AI 计费设置设置为统一计费。通过该网关路由的 Workers AI 请求会实时从您的积分余额中扣除。
Prepaid credits also provide access to the following Workers AI frontier models without requiring the Workers Paid plan. Each frontier Workers AI model has a rate limit of 50 requests per minute per account, per model when billed with AI Gateway credits, compared to 20 requests per minute through standard Workers AI billing:
预付费积分还允许访问以下 Workers AI 前沿模型,而无需 Workers Paid 计划。每个前沿 Workers AI 模型在使用 AI Gateway 积分计费时,每个账户每个模型的速率限制为每分钟 50 个请求,而通过标准 Workers AI 计费为每分钟 20 个请求:
- @cf/moonshotai/kimi-k2.6
- @cf/moonshotai/kimi-k2.7-code
- @cf/zai-org/glm-5.2
- @cf/moonshotai/kimi-k2.6
- @cf/moonshotai/kimi-k2.7-code
- @cf/zai-org/glm-5.2
These limits are designed for typical agentic and coding workloads, where requests to frontier models can take longer to complete.
这些限制专为典型的代理和编码工作负载而设计,其中对前沿模型的请求可能需要更长时间才能完成。
For details, refer to Workers AI limits, Workers AI pricing, Unified Billing, and the AI Gateway model catalog.
有关详细信息,请参阅 Workers AI 限制、Workers AI 定价、统一计费和 AI Gateway 模型目录。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力