Prerequisites
1. Create an agent (with your Anthropic key)
An agent is the reusable “what” — a name, a prompt, and a model. Sessions run the model on your Anthropic key, so pass it inline withkey. It’s held in OpenComputer’s secret store (encrypted, write-only); the real key never enters the sandbox — it’s sealed, and a host proxy reveals it only on the outbound call to Anthropic, so it’s never exposed to the model or the agent’s code.
2. Start a session
Start a session on the agent with a task. Add an optionalwebhook to receive every event from the start.
Reuse the agent across as many sessions as you like. To bound a run, pass
limits: { tokens?, turn_seconds?, turns? } on the agent or the session.3. Stream it live
Open anEventSource with the client_token from the create call. It rides the query string — browsers can’t set headers on EventSource, so the scoped client token goes in the URL (never your API key). level=user shows only what an end user should see (see levels).
seq as the SSE event id, so on a dropped connection EventSource reconnects and resends Last-Event-ID — you pick up exactly where you left off, no bookkeeping. (Pass after=<seq> on the URL to start from a specific point.)
4. Steer it
Send a follow-up at any time. The session wakes and continues with its prior context.5. Manage destinations (optional)
You already passed awebhook at create. Add or manage more destinations later — each receives events from when it’s created (earlier events aren’t backfilled yet).
webhook-id. See Webhooks to verify the signature and inspect deliveries.
Next steps
Sessions
How a session works — lifecycle and events.
Webhooks
Deliver output reliably, and control deliveries.
Example apps
A repo of examples built on this API.