Skip to main content

Build an Agent from a URL in 5 Minutes

This quickstart takes you from zero to an embedded, grounded chat agent built from a creator’s YouTube or Instagram channel. The flow:
1

Create an org + API key

Get a brs_live_ key with the agents:write scope.
2

Provision from a URL

Your backend POSTs to /v1/agents:from-url202 with a buildId.
3

Stream progress

Your backend consumes the SSE stream and relays progress to the browser.
4

Chat

On ready, the browser chats directly with the agent’s public slug.
The brs_live_ key is a server-side secret. NEVER ship it to a browser. The recommended (and only v1) integration is Pattern A below: your backend holds the key and relays events; the browser talks to your backend, then chats directly with the anonymous slug endpoints.

1. Create an org + API key

API keys are organization-scoped — all provisioned agents and their cost bill to that org. Create (or pick) a Brainstormer org, then mint an API key with the agents:write scope (chat needs chat, which is a default scope). Set the key in your backend environment — never in client code:
See Authentication & rate limits for scopes, Turnstile, rate limits, and idempotency.

2. Provision from a URL

Your backend submits the build. The request returns immediately (202) — it does not block while the agent is built.
Backend — submit build
If status is already ready (a handle-dedup cache hit), skip straight to step 4 with build.agentSlug.

3. Stream progress (and relay to the browser)

The SSE stream requires the Authorization header, so it must be consumed server-side (the browser’s EventSource can’t send headers). Your backend reads the stream and relays each event to the browser over your own SSE/WebSocket.
Backend — consume + relay
See the full SSE reference for the wire format, the eventsource-package variant, and reconnect via Last-Event-ID.

Pattern A: backend proxy (Next.js)

A complete reference: a Next.js Route Handler that holds the key and streams a relay to the browser. The browser opens an EventSource against your route, never against Brainstormer.
app/api/build/route.ts (Next.js Route Handler)
Browser — talk only to YOUR backend
For an “email-me-a-link” UX where you don’t hold a connection, set deliver.webhookUrl and verify the HMAC-signed webhook instead of streaming — or poll the snapshot endpoint.

4. Chat from the browser

Once you have agentSlug, the browser chats directly — no key, no proxy. Generate a UUID anonymousId per visitor and seed the UI with the starterQuestions from the ready event.
Browser — chat
See the full Anonymous Chat reference.
If the agent has file uploads enabled, visitors can attach files: upload via POST /api/public/agents/:slug/attachments and pass the returned { id, accessToken } in the message’s attachments array.

Next steps

Authentication & rate limits

Scopes, Turnstile, 429 / Retry-After, idempotency.

Build lifecycle

The FSM, preview vs. full ingestion, dedup, and preview TTL.

from-url reference

Every request/response field and status code.

SSE reference

Wire format, ProvisioningEvent, error codes.