Get started
To use the Agent starter template and create your first Agent with the Agents SDK:
-
Create a new project using the
agents-startertemplate.Terminal window # install itnpm create cloudflare@latest agents-starter -- --template=cloudflare/agents-starter -
Deploy the project.
Terminal window #deploy itnpx wrangler@latest deploy
-
Install the
agentspackage directly into an existing project:Terminal window npm i agents -
Define your first Agent by creating a class that extends the
Agentclass:import { Agent, AgentNamespace } from "agents";export class MyAgent extends Agent {// Define methods on the Agent:// https://developers.cloudflare.com/agents/api-reference/agents-api///// Every Agent has built in state via this.setState and this.sql// Built-in scheduling via this.schedule// Agents support WebSockets, HTTP requests, state synchronization and// can run for seconds, minutes or hours: as long as the tasks need.}import { Agent, AgentNamespace } from "agents";export class MyAgent extends Agent {// Define methods on the Agent:// https://developers.cloudflare.com/agents/api-reference/agents-api///// Every Agent has built in state via this.setState and this.sql// Built-in scheduling via this.schedule// Agents support WebSockets, HTTP requests, state synchronization and// can run for seconds, minutes or hours: as long as the tasks need.} -
Add the Durable Objects binding to your wrangler file:
{"durable_objects": {"bindings": [{"name": "MyAgent","class_name": "MyAgent"}]},"migrations": [{"tag": "v1","new_sqlite_classes": ["MyAgent"]}]}[[durable_objects.bindings]]name = "MyAgent"class_name = "MyAgent"[[migrations]]tag = "v1"new_sqlite_classes = ["MyAgent"]
Dive into the Agent SDK reference to learn more about how to use the Agents SDK package and defining an Agent.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark