Skip to main content
This guide walks you through creating an agent, setting up an environment, starting a session, and streaming agent responses.

Core concepts

Prerequisites

  • A reachable OMA deployment
  • An API key

Install the CLI

Check the installation:

Install the SDK

Set your API key as an environment variable:

Create your first session

Managed Agents API requests require the managed-agents-2026-04-01 beta header, except memory store endpoints, which use agent-memory-2026-07-22 instead. The SDK sets the correct beta header automatically. See Beta headers.
1

Create an agent

Create an agent that defines the model, system prompt, and available tools.
The agent_toolset_20260401 tool type enables the full set of pre-built agent tools (bash, file operations, web search, and more). See Tools for the complete list and per-tool configuration options.Save the returned agent.id. You’ll reference it in every session you create.
2

Create an environment

An environment defines the sandbox where your agent runs.
Save the returned environment.id. You’ll reference it in every session you create.
To run the sandbox on your own infrastructure instead of a cloud sandbox, seeSelf-hosted sandboxes.
3

Start a session

Create a session that references your agent and environment.
4

Send a message and stream the response

Open a stream, send a user event, then process events as they arrive:
The agent writes a Python script, runs it in the sandbox, and verifies the output file was created. Your output looks similar to this:

What’s happening

When you send a user event, Open Managed Agents:
  1. Provisions a sandbox: Your environment configuration determines how it’s built.
  2. Runs the agent loop: The agent 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 Open 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

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

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)

A personal finance assistant in a CopilotKit chat. The AG-UI adapter for Open 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

Create reusable, versioned agent configurations

Configure environments

Customize networking and sandbox settings

Agent tools

Enable specific tools for your agent

Session event stream

Handle events and steer the agent mid-execution

Scheduled deployments

Run your agent on a recurring cron schedule

Knowledge wiki quickstart

Distill a document corpus once into a knowledge wiki, then answer repeated questions from it at a fraction of the cost