Hand it to your AI agent
Copy this prompt into Claude Code, Cursor, Codex or any coding agent. It tells the agent where the docs are and how to use your API key.
Use the Lovely Router browser agent API: a real browser that clicks, types, fills forms and logs in for a task, and returns an answer plus JSON in a schema I choose.
- Docs (read first): https://lovelyrouter.com/docs/browser-agent.md and https://lovelyrouter.com/docs/api/browser.md
- Start a run: POST https://lovelyrouter.com/v1/browser/runs with `{"goal": "...", "start_url": "https://...", "output_schema": {...}}`. Put every value the task needs in the goal. It returns 202 at once; poll the `poll` path (or stream `events`) until the run ends, then read `answer` and `data`.
- Billed per step (fast mode by default). Set `max_steps` to cap a run. For unattended runs send `"human": false`; by default the agent pauses before purchases, sending or deleting (`approve`).
- If you support MCP, you can instead connect the server https://lovelyrouter.com/mcp (Streamable HTTP, same key; https://lovelyrouter.com/docs/tools/mcp.md) and use suggest_tools, get_tool and run_tool.
- Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys.
- Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large.
- Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt.
My task: <describe the site and what the agent should do or extract>Input
goalstringrequiredWhat to do, in plain words, with every value the task needs
start_urlstringrequiredPage to start on
modestringfast (default, $0.006/step) or accurate ($0.012/step: screenshots when unsure + read-only page code; higher success on hard sites)
fast · accurate
output_schemaobjectOptional JSON Schema (or {"field": "type"} shorthand) for structured output in `data`; omit for data: null
modelstringOptional model id from /v1/models (e.g. claude-sonnet-5.5) for the agent's reasoning; its tokens are billed at the normal price × 1.2 on top of the step price
secretsstring[]Names of vault secrets the agent may fill (never shown to the model)
profilestringSaved browser profile (cookies) to start from
save_profilestringSave cookies under this profile name when done
human_timeout_minutesnumberHow long to wait for a human reply or approval, 1–1440 minutes (default 30); time beyond 1 minute per step costs $0.005/min
approvestringPause for approval before risky submits (default risky)
none · risky · submit
Try it
Call it from code
How runs, polling and billing work →curl https://lovelyrouter.com/v1/tools/browser-agent/run \
-H "Authorization: Bearer $LOVELY_API_KEY" \
-H "content-type: application/json" \
-d '{"input":{"goal":"Find the price of the book '\''A Light in the Attic'\''","start_url":"https://books.toscrape.com/"},"max_results":50}'# MCP (agents): suggest_tools → get_tool → run_tool
run_tool({
"tool": "browser-agent",
"input": {"goal":"Find the price of the book 'A Light in the Attic'","start_url":"https://books.toscrape.com/"},
"max_results": 50
})What it costs
| Results | Runs (at 100 per run) | Cost |
|---|---|---|
| 100 | 1 | $0.60 |
| 1,000 | 10 | $6.00 |
| 10,000 | 100 | $60.00 |
Prepaid, no subscription. Fewer results than requested cost less. Pricing
Used for
Frequently asked questions
How much does the Browser agent API cost?
$0.006 / step. 1,000 results, fetched in runs of up to 100, cost $6.00. There is no subscription: you pay from a prepaid balance.
Is this an AI browser automation API?
Yes. If you searched for an AI browser automation API, an AI web agent API or a headless browser agent, this is it: Give it a goal and a start page; an AI agent drives a real browser to do it: navigate, fill forms, log in with saved secrets, ask you for codes, hand over for CAPTCHAs, wait for your approval before purchases, and return structured JSON in your schema. For tasks that need interaction; to just read a page, use Read a web page (web-fetch). $0.006 per step in fast mode, $0.012 in accurate mode (looks at screenshots when unsure, can run read-only code to read data). Each step includes 1 minute; time beyond that (e.g. waiting for your approval) costs $0.005/min. Full API: /v1/browser.
How many results does one run return?
50 by default and up to 100 per run. Set max_results to cap a run: you are billed only for the results it delivers.
Can an AI agent use this tool?
Yes. Connect Claude Code, Cursor or any MCP client to the Lovely Router MCP server: the agent finds the tool with suggest_tools and runs it with run_tool and the id browser-agent.
What happens if a run fails?
A run that fails or is stopped pays only for the results it delivered, with no call fee. The most a run can cost is held when it starts and the rest is released when it settles.