Agents
Build AI agents that remember, reason, and act
The Agents SDK gives you the primitives to build proactive, stateful AI agents on Cloudflare. Built-in memory, scheduling, email handling, and real-time communication — agents that don't just respond, but take initiative.
Built-in memory
Proactive by design
Multiplayer by default
How Agents work

Stateful by default
Each agent instance is a Durable Object with its own SQLite database. State persists automatically across requests and hibernation cycles.

Real-time communication
WebSockets with automatic hibernation, resumable streams, and state sync. Build chat, collaboration, or multiplayer experiences.

Proactive scheduling
Schedule tasks with cron expressions, respond to incoming emails, or trigger actions from webhooks and queue messages.

MCP integration
Connect to any MCP server to give agents access to external tools, APIs, and data sources.
Proactive assistants
Real-time collaboration
Messaging and notifications
From chat to code to orchestration
The Agents SDK handles state, streaming, and tool integration so you can focus on what your agent does.

import { routeAgentRequest } from "agents"; import { AIChatAgent } from "@cloudflare/ai-chat"; import { streamText, convertToModelMessages } from "ai"; import { openai } from "@ai-sdk/openai"; export class ChatAgent extends AIChatAgent<Env> { async onChatMessage(onFinish) { const result = streamText({ model: openai("gpt-5"), messages: await convertToModelMessages(this.messages), onFinish, }); return result.toUIMessageStreamResponse(); } } export default { async fetch(request: Request, env: Env) { return (await routeAgentRequest(request, env)) || new Response("Not found", { status: 404 }); }, };
Powerful primitives, seamlessly integrated
Built on systems powering 20% of the Internet, the Agents SDK builds on the same infrastructure Cloudflare uses to build Cloudflare. Enterprise-grade reliability, security, and performance are standard.
Compute
Storage
AI
Media
Build without boundaries
Join thousands of developers who've eliminated infrastructure complexity and deployed globally with Cloudflare. Start building for free — no credit card required.