--- url: "https://platform.claude.com/docs/en/managed-agents/quickstart" titulek: "Get started with Claude Managed Agents - Claude Platform Docs" h1: "Get started with Claude Managed Agents" popis: "Create your first autonomous agent." jazyk: "en" kanonicka: "https://platform.claude.com/docs/en/managed-agents/quickstart" drobecky: ["Managed Agents", "Get started with Claude Managed Agents"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 12:00:49" znaku: 6141 slov: 848 kodovani: "utf-8" sha256: "ef19ec2f1ad9c564cc4bd482efea9e64e82555fc469c0120ca6767689fba8ab2" --- This guide walks you through creating an agent, setting up an environment, starting a session, and streaming agent responses. ## Core concepts | Concept | Description | | --- | --- | | **Agent** | The model, system prompt, tools, MCP servers, and skills | | **Environment** | Configuration for where sessions run: an Anthropic-managed cloud sandbox, or a self-hosted sandbox on your own infrastructure | | **Session** | A running agent instance within an environment, performing a specific task and generating outputs | | **Events** | Messages exchanged between your application and the agent (user turns, tool results, status updates) | ## Prerequisites - A [Claude Console account](https://platform.claude.com) - An [API key](/settings/keys) ## Install the CLI ``` brew install anthropics/tap/ant ``` Check the installation: ``` ant --version ``` ## Install the SDK ``` pip install anthropic ``` Set your API key as an environment variable: ``` export ANTHROPIC_API_KEY="your-api-key-here" ``` ## Create your first session 1. 1 Create an agentCreate an agent that defines the model, system prompt, and available tools.`ant apply coding-assistant.md`coding-assistant.md`--- name: Coding Assistant model: claude-opus-5 tools: - type: agent_toolset_20260401 --- You are a helpful coding assistant. Write clean, well-documented code.`The `agent_toolset_20260401` tool type enables the full set of pre-built agent tools (bash, file operations, web search, and more). See [Tools](/docs/en/managed-agents/tools) for the complete list and per-tool configuration options.Save the returned `agent.id` (the CLI's [`ant apply`](/docs/en/cli-sdks-libraries/cli/apply) prints it and records it in `claude-lock.json`). You'll reference it in every session you create. 2. 2 Create an environmentAn environment defines the sandbox where your agent runs.`ant apply environment.yaml`environment.yaml`name: quickstart-env config: type: cloud networking: type: unrestricted`Save the returned `environment.id` (also in `claude-lock.json` if you used `ant apply`). You'll reference it in every session you create. 3. 3 Start a sessionCreate a session that references your agent and environment.`session = client.beta.sessions.create( agent=agent.id, environment_id=environment.id, title="Quickstart session", ) print(f"Session ID: {session.id}")` 4. 4 Send a message and stream the responseOpen a stream, send a user event, then process events as they arrive:`with client.beta.sessions.events.stream(session.id) as stream: # Send the user message after the stream opens client.beta.sessions.events.send( session.id, events=[ { "type": "user.message", "content": [ { "type": "text", "text": "Create a Python script that generates the first 20 Fibonacci numbers and saves them to fibonacci.txt", }, ], }, ], ) # Process streaming events for event in stream: match event.type: case "agent.message": for block in event.content: if block.type == "text": print(block.text, end="") case "agent.tool_use": print(f"\n[Using tool: {event.name}]") case "session.status_idle": print("\n\nAgent finished.") break`The agent writes a Python script, runs it in the sandbox, and verifies the output file was created. Your output looks similar to this:`I'll create a Python script that generates the first 20 Fibonacci numbers and saves them to a file. [Using tool: write] [Using tool: bash] The script ran successfully. Let me verify the output file. [Using tool: bash] fibonacci.txt contains the first 20 Fibonacci numbers (0 through 4181). Agent finished.` ## What's happening When you send a user event, Claude Managed Agents: 1. **Provisions a sandbox:** Your environment configuration determines how it's built. 2. **Runs the agent loop:** Claude determines which tools to use based on your message. 3. **Runs tools:** File writes, bash commands, and other tool calls run inside the sandbox. 4. **Streams events:** You receive real-time updates as the agent works. 5. **Goes idle:** The agent emits a `session.status_idle` event when it has nothing more to do. ## Build a complete app Each of these quickstarts pairs Claude Managed Agents with a popular chat framework to make a complete, runnable application. In each one, the framework renders the chat surface while a managed session runs the agent loop server-side: the session holds the transcript, runs tools in a sandbox, and streams events that the front end renders. [Chat SDK](https://github.com/anthropics/claude-quickstarts/tree/main/managed-agents/chat-sdk)  A research analyst in a browser chat built with Vercel's Chat SDK. Each conversation is one persistent session that streams its reply while a live feed shows the tool calls. Swapping the Chat SDK adapter moves the same handler to Slack, Teams, Discord, or WhatsApp. [assistant-ui](https://github.com/anthropics/claude-quickstarts/tree/main/managed-agents/assistant-ui)  A spreadsheet analyst in a chat built from assistant-ui primitives. Sessions are the thread list, one reducer turns the session event log into messages and tool cards, and each bash command renders an inline Allow/Deny gate before it runs. [CopilotKit (AG-UI)](https://github.com/anthropics/claude-quickstarts/tree/main/managed-agents/copilot-kit-ag-ui)  A personal finance assistant in a CopilotKit chat. The AG-UI adapter for Claude Managed Agents maps each chat thread to a managed session and streams replies token by token, and custom tools render interactive charts inline in the conversation. ## Next steps  [Define your agent](/docs/en/managed-agents/agent-setup) Create reusable, versioned agent configurations  [Configure environments](/docs/en/managed-agents/environments) Customize networking and sandbox settings  [Agent tools](/docs/en/managed-agents/tools) Enable specific tools for your agent  [Session event stream](/docs/en/managed-agents/events-and-streaming) Handle events and steer the agent mid-execution  [Scheduled deployments](/docs/en/managed-agents/scheduled-deployments) Run your agent on a recurring cron schedule [Knowledge wiki quickstart](https://github.com/anthropics/claude-quickstarts/tree/main/managed-agents/knowledge-wiki)  Distill a document corpus once into a knowledge wiki, then answer repeated questions from it at a fraction of the cost Was this page helpful?