The Agents SDK has added a createAI helper that replaces the older workers-ai-provider and ai-gateway-provider bindings. The new function lets you address Workers AI models, AI Gateway catalog entries, dynamic routes, and vendor‑specific models through either the built‑in AI binding or explicit account credentials. Both legacy providers are now feature‑frozen and marked deprecated, so teams should plan migration at their own pace.
Unified Model Access via createAI
Instead of wiring separate providers for Workers AI and AI Gateway, createAI accepts a configuration object that can reference the AI binding (e.g., env.AI) or an account identifier with an API token. The function returns a callable that resolves a model name to an executable endpoint, handling fallback logic internally. This reduces the surface area of configuration files and eliminates the need to maintain two distinct provider imports.
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();
},
};
Migration Path from Deprecated Providers
Since the older providers are now frozen, existing deployments that import workers-ai-provider or ai-gateway-provider will continue to run but will not receive new features. Engineers should replace those imports with createAI and adjust any configuration that previously referenced separate bindings. The migration is straightforward because the new API mirrors the prior model‑selection pattern, only differing in the entry point.
Operational and Security Implications
Consolidating model access into a single function reduces the number of secrets that need to be managed. When using the binding approach, the platform supplies credentials automatically, limiting exposure of raw API tokens. If an account ID and token are supplied directly, teams must continue to protect those values in environment variables or secret stores. The unified interface also means that logging, monitoring, and rate‑limiting can be applied at a single layer rather than duplicated across two providers.
Related CloudNinjas coverage: AI engineering.
What This Means For Practitioners
Adopt createAI in new code to benefit from a single, future‑proofed entry point for all Cloudflare AI model integrations. For existing services, schedule a migration to replace the deprecated providers, verify that fallback models still resolve, and confirm that credential handling aligns with your security policies. Keep an eye on Cloudflare announcements for any further deprecation timelines or enhancements to the createAI API.


