Changelog (23)
Last updated Jun 5, 2026
2026-10-21
createAI replaces workers-ai-provider and ai-gateway-provider
The Agents SDK has a new createAI function for the AI SDK and Pi AI. It unifies what workers-ai-provider and ai-gateway-provider did: Workers AI models, AI Gateway catalog models, dynamic routes, and vendor models, through the AI binding or an account id and API token.
workers-ai-provider and ai-gateway-provider are now feature frozen and marked as deprecated. Please migrate at your convenience.
npm i agents
import { createAI } from "agents/models/ai-sdk";
import { streamText } from "ai";
export default {
async fetch(request, env) {
const ai = createAI({ binding: env.AI, id: "my-gateway" });
const result = streamText({
model: ai("anthropic/claude-opus-5.5", {
fallback: ["@cf/zai-org/glm-4.7-flash"],
}),
prompt: "Write a haiku about Durable Objects",
});
return result.toTextStreamResponse();
},
};
import { createAI } from "agents/models/ai-sdk";
import { streamText } from "ai";
export default {
async fetch(request: Request, env: Env) {
const ai = createAI({ binding: env.AI, id: "my-gateway" });
const result = streamText({
model: ai("anthropic/claude-opus-5.5", {
fallback: ["@cf/zai-org/glm-4.7-flash"],
}),
prompt: "Write a haiku about Durable Objects",
});
return result.toTextStreamResponse();
},
};
With createAI you get:
- Every model by id. Workers AI
@cf/ids, any model in the AI Gateway catalog, and dynamic routes asdynamic/<route>. - Vendor model objects. Pass a model from the vendor's own package, such as
ai(anthropic("claude-opus-5-5")). It goes unchanged to AI Gateway's provider-native endpoint. - The binding, or an account id and API token. Use a gateway in another account, or call from outside a Worker.
- Gateway options, fallback, and BYOK. Caching, logging, metadata, retries,
byokAlias,zdr, andvendorKey. - Stream resume. Through the binding, a catalog or dynamic route stream that drops mid-answer resumes.
- Other model types. Embeddings, images, speech, transcription, and reranking in the AI SDK provider, and images in Pi AI.
| Before | After |
|---|---|
createWorkersAI({ binding }) |
createAI({ binding }) |
createWorkersAI({ accountId, apiKey }) |
createAI({ accountId, apiToken }) |
createAiGateway(...) |
createAI(...), with fallback for a list of models |
createAISearch from workers-ai-provider |
createAISearchNamespace from ai-search-provider |
For AI Search, use ai-search-provider. For more information, refer to Models.
2026-10-08
AI Gateway log IDs and request IDs now use UUIDv7
New AI Gateway log IDs and request IDs are lowercase UUIDv7, such as 019a7b3e-5f2c-7c41-9d3e-2b8f6a1c4e07. Previously, log IDs were 26-character ULIDs and request IDs were random UUIDs.
For a request that AI Gateway answers in a single step, the cf-aig-request-id, cf-aig-log-id, and cf-aig-event-id response headers now carry the same value. For provider and Universal requests, if you set your own cf-aig-event-id, AI Gateway returns it instead.
Existing log IDs do not change, and the logs API accepts both formats. Treat log IDs as opaque strings, and update any code that checks for the ULID format.
2026-10-06
Standardize provider credential error responses in AI Gateway
AI Gateway's REST API now returns consistent responses when an AI provider rejects credentials. The change applies to POST /ai/run ↗︎.
| Scenario | Previous AI Gateway response | New AI Gateway response |
|---|---|---|
| ElevenLabs | Provider-specific UserCredentialsError with HTTP 403 |
HTTP 401 with error code 2009 |
| Google Vertex | HTTP 500 for rejected credentials, with upstream retries |
HTTP 401 with error code 2009; the request fails without retrying the provider |
| All other providers | HTTP 402 or another provider-specific status for rejected credentials |
HTTP 401 with error code 2009 |
| When using Unified Billing, the provider rejects the credentials | Provider-specific authentication error | HTTP 503 |
Update applications that handle AI Gateway REST API errors to treat HTTP 401 as an invalid or rejected provider credential.
For details about providing provider credentials, refer to Bring your own provider keys.
2026-10-02
Introducing Web Search API
Web Search API is now available in beta. Web Search API lets your AI agents and applications search the Internet and ground their responses in live information, instead of guessing URLs or relying on a model's training cutoff.
At launch, you can choose between three search providers: Ceramic.ai, Exa, and Linkup. All three support Zero Data Retention for requests made through Cloudflare, and all have committed to Cloudflare's verified bot crawling standards.
Web Search API runs through AI Gateway, so search requests appear in your gateway logs and are billed to your AI Gateway credits at each provider's list API price, with no additional markup. You can also bring your own provider API key.
Call Web Search API with the REST API:
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/websearch/ \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"query": "What are some fun things to do in Salt Lake City as fall approaches?",
"provider": "ceramic",
"limit": 5,
"options": { "gateway": { "id": "default" } }
}'
Or from a Worker with the AI binding:
const response = await env.AI.websearch({
gatewayId: "default",
query: "What are some fun things to do in Salt Lake City as fall approaches?",
provider: "exa",
limit: 5,
});
const results = await response.json();
To get started, refer to How to use Web Search API.
2026-09-30
Pay for AI inference with Machine Payments
AI Gateway now supports Machine Payments in beta. With Machine Payments, clients can use the x402 protocol to pay for eligible inference requests directly from a stablecoin wallet instead of maintaining a prepaid credit balance.
Machine Payments is available for the /ai/run endpoint with select open models. To request x402 payment, authenticate with a Cloudflare API token and include the Cloudflare-specific Payment-Method: x402 header:
curl -iX POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run" \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Payment-Method: x402" \
--header "Content-Type: application/json" \
--data '{
"model": "z-ai/glm-4.7-flash",
"input": {
"messages": [
{
"role": "user",
"content": "What is Cloudflare?"
}
]
}
}'
An x402-compatible client handles the payment challenge, signs an authorization from the client's wallet, and retries the request. Machine Payments currently requires customers to be based in the United States and have a credit card on file.
For prerequisites, eligible models, and transaction details, refer to Machine Payments (x402).
2026-09-29
Identify model overuse and potential savings with User Insights
AI Gateway User Insights now gives you more context about the traffic flowing through your gateway. It shows what users and agents are doing with AI, and where a selected model may be more capable than a task requires.
On the analysis side, User Insights groups conversations by task, tracks conversation turns, and helps you compare model fit with cost and latency.

The Potential Savings view highlights requests that may work with faster or less expensive models without compromising output quality. These are the same signals that Cloudflare's Auto Router uses to select a model based on task and cost.

These new insights are available to all AI Gateway customers at no additional cost. For more information, refer to User Insights.
2026-09-14
Prevent Unified Billing fallback for BYOK third-party providers
AI Gateway can now require credentials for third-party provider requests. Credentials must accompany the request or be stored on the gateway. This setting prevents fallback to Unified Billing with Cloudflare-managed credentials.
Turn on Require provider credentials in your gateway settings. To use the API, set byok_only to true in the request body of a PUT request to update the gateway:
{
"byok_only": true
}
To require provider credentials for one third-party request, set the cf-aig-no-wholesale header to true. This header cannot relax the gateway setting.
Requests without applicable credentials then return an HTTP 400 response. Workers AI requests remain allowed, and the setting does not change their configured billing mode.
For configuration details and request-level controls, refer to Prevent Unified Billing fallback for BYOK third-party providers.
2026-09-09
AI Gateway custom costs support cache tokens
AI Gateway custom costs now support cache-read and cache-write token rates. This lets custom cost metrics reflect negotiated cache pricing across providers.
Add per_cache_read_token or per_cache_write_token to the cf-aig-custom-cost header:
{
"per_token_in": 0.000001,
"per_token_out": 0.000002,
"per_cache_read_token": 0.0000001,
"per_cache_write_token": 0.0000005
}
Cache-token pricing activates when either cache rate is present. An omitted cache rate defaults to per_token_in. If both cache rates are omitted, AI Gateway preserves the existing input and output calculation.
Providers can include cache tokens within input tokens or report them separately. AI Gateway automatically accounts for these differences and prevents double-counting.
For more information, refer to Custom costs.
2026-09-01
AI Gateway consolidates monthly usage invoice line items and standardizes model names
AI Gateway monthly usage invoices, issued at the beginning of each month for the previous month's usage, now show a single total cost for each model. These invoices no longer break out input and output token quantities and unit prices into separate line items. This change does not apply to invoices for AI Gateway credit purchases.
For example, an invoice that previously included these separate line items:
anthropic claude-haiku-4-5-20251001 Input Tokens: 40,000 tokens at $0.000001 ($0.04)anthropic claude-haiku-4-5-20251001 Output Tokens: 24,000 tokens at $0.000005 ($0.12)
The updated invoice includes one line item: anthropic/claude-haiku-4.5: $0.16.
AI Gateway has also standardized model names across invoices and logs. Model variants that previously appeared with provider-specific version suffixes now use a consistent provider/model identifier.
For more information, refer to the Unified Billing documentation and AI Gateway logging documentation.
2026-08-19
Get 50% off GPT-5.6 Sol through AI Gateway
GPT-5.6 Sol is available through AI Gateway, and for a limited time you can use it at 50% off. If you are already using AI Gateway, point to the openai/gpt-5.6-sol model and the discounted pricing applies automatically — no promo code needed.
The promotion is available for Unified Billing users only (not Bring Your Own Keys). Load credits onto AI Gateway and start sending requests to openai/gpt-5.6-sol.
Discounted pricing during the promotion:
| Usage | Promotional price | Standard price |
|---|---|---|
| Input | $2.50 per 1M tokens | $5 per 1M tokens |
| Output | $15 per 1M tokens | $30 per 1M tokens |
| Cache read | $0.25 per 1M tokens | $0.50 per 1M tokens |
The promotion runs through September 18, 2026. After that date, GPT-5.6 Sol requests return to standard pricing.
For more details, refer to the Unified Billing documentation and the GPT-5.6 Sol model page.
2026-08-07
Workers AI and AI Gateway unify model access and billing
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.
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.
