Run a Hosted Agent

View as Markdown

The zero-framework path: create a runtime, hand it an instruction, read the answer. The agent runs inside the runtime on BCTRL infrastructure - your process just waits for the result, and the whole session is recorded on the run like any other.

1import { Bctrl } from "@bctrl/sdk";
2
3const bctrl = new Bctrl({ apiKey: process.env.BCTRL_API_KEY! });
4
5const runtime = await bctrl.runtimes.create({
6 type: "browser",
7 name: "agent-recipe",
8 config: { stealth: "high" },
9});
10const { runId } = await bctrl.runtimes.start(runtime.id);
11
12const invocation = await bctrl.runtimes.invocations.createAndWait(
13 runtime.id,
14 {
15 action: "browserUse",
16 instruction:
17 "Go to news.ycombinator.com and summarize the top three stories, with links.",
18 maxSteps: 25,
19 useVision: "auto",
20 },
21 { timeoutMs: 300_000 }
22);
23
24console.log(invocation.status);
25console.log(invocation.output);
26
27await bctrl.runtimes.stop(runtime.id);
28
29// Proof of work: replay exactly what the agent did.
30const recording = await bctrl.runs.recording(runId);
31console.log("Replay:", recording.url);

📸 Content TODO: screenshot of the recording viewer scrubbed to mid-task, captioned “what the agent actually did” - the replay-as-proof framing is the hook here.

While it runs, everything from the other recipes applies: watch it live, stream its events, or solve the CAPTCHA it hits - or grant the captcha builtin via a toolset and it solves them itself.

Choosing a model

By default the space’s configured model is used. Override per call with a managed model string, or your own key via a saved AI credential:

1{
2 action: "browserUse",
3 instruction: "...",
4 model: "openai/gpt-5",
5}

browser-use exposes deeper controls when you need them - enablePlanning, maxFailures, stepTimeoutMs, sensitiveData - see Hosted agents.

Next