---
description: The Agents SDK has a new createAI function for the AI SDK and Pi AI that unifies workers-ai-provider and ai-gateway-provider. Both packages are now feature frozen and marked as deprecated.
title: createAI replaces workers-ai-provider and ai-gateway-provider
image: https://developers.cloudflare.com/changelog/post/2026-10-21-createai/og.png?v=775c1bfaabc5759a
---

[Skip to content](#main-content)

[View RSS feeds](https://developers.cloudflare.com/fundamentals/new-features/available-rss-feeds/) [ Subscribe to RSS](https://developers.cloudflare.com/changelog/rss/index.xml)

[Back to all posts](https://developers.cloudflare.com/changelog)

October 21, 2026

## createAI replaces workers-ai-provider and ai-gateway-provider

[Agents](https://developers.cloudflare.com/agents/) [Workers AI](https://developers.cloudflare.com/workers-ai/) [AI Gateway](https://developers.cloudflare.com/ai-gateway/)

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/changelog/post/2026-10-21-createai/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

The Agents SDK has a new [`createAI`](https://developers.cloudflare.com/agents/models/) function for the [AI SDK](https://developers.cloudflare.com/agents/models/ai-sdk/) and [Pi AI](https://developers.cloudflare.com/agents/models/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.

```sh
npm i agents
```

```js
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();
	},
};
```

```ts
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](https://developers.cloudflare.com/ai/models/), and [dynamic routes](https://developers.cloudflare.com/ai-gateway/features/routing/dynamic-routing/) as `dynamic/<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](https://developers.cloudflare.com/ai-gateway/usage/providers/).
- **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`, and `vendorKey`.
- **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`](https://developers.cloudflare.com/ai-search/agent-sdks/ai-sdk/). For more information, refer to [Models](https://developers.cloudflare.com/agents/models/).

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://developers.cloudflare.com/changelog/post/2026-10-21-createai/#page","headline":"createAI replaces workers-ai-provider and ai-gateway-provider","description":"The Agents SDK has a new createAI function for the AI SDK and Pi AI that unifies workers-ai-provider and ai-gateway-provider. Both packages are now feature frozen and marked as deprecated.","url":"https://developers.cloudflare.com/changelog/post/2026-10-21-createai/","inLanguage":"en","image":"https://developers.cloudflare.com/changelog/post/2026-10-21-createai/og.png?v=775c1bfaabc5759a","dateModified":"2026-10-21","datePublished":"2026-10-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
