Prerequisites
- A Mobilerun account. You can sign up at cloud.mobilerun.ai.
- A cloud API key that starts with
dr_sk_from the API Keys page. This is the only credential you need, because the agent’s LLM usage is billed from your credit balance and you do not need your own model key. - A ready device. You can connect your own phone with the Portal app, or provision a Cloud Phone or a Physical Phone in the dashboard.
Autonomous tasks consume credits at roughly 0.5 credits per agent step. New accounts
and device subscriptions include a monthly credit allowance.
1. Set your API key
The examples below read your key from theMOBILERUN_API_KEY environment variable.
If you call
new Mobilerun() without an apiKey, the TypeScript SDK auto-detects the
MOBILERUN_CLOUD_API_KEY variable instead. The examples pass the key explicitly, so either name
works.The TypeScript example uses top level
await, so run it as an ES module. Set "type": "module"
in your package.json or use a .mts file, and then run it with npx tsx quickstart.ts.2. Install
3. Run your first task
Each example does the same four things. It lists a ready device, submits a task, polls until the task finishes, and prints the result.The trajectory is returned as
{ "trajectory": [ ... ] }, which is an array of events. The final
result is the event whose event field equals "ResultEvent", and its data holds the fields
success, message, structured_output, and steps. For data extraction tasks you can pass an
outputSchema in JSON Schema form when you create the task, and then structured_output is
populated with data matching it. See Agent configuration for more.Read the result without the trajectory
The trajectory is the full step by step record, which is useful when you want to inspect every screenshot and action. For most tasks you do not need it, because the status endpoint already returns the answer. AGET /tasks/{id}/status call returns the task outcome directly.
message field holds the agent’s natural language answer. The output field holds your
structured data when you submitted an outputSchema, and it is null otherwise. Because the
polling loop in step 3 already calls this endpoint, you can read message and output straight
from the final poll and skip the trajectory call entirely.
Choosing a model
PassllmModel to pick the model that drives the agent. Use one of the identifiers from the
cloud model catalog. For example, mobilerun/mobile-agent-fast is tuned
for speed and cost, while mobilerun/mobile-agent-thinking gives stronger reasoning for complex
flows. Omit the field to use your account default.
Next steps
Agent configuration
All task parameters, including models, vision, reasoning, stealth, memory, and structured
output.
API Reference
Full REST schemas for every endpoint, with request and response examples.
MCP Server
Drive Mobilerun from Cursor, Claude Desktop, and other MCP clients.
Webhooks
Get notified when tasks change state instead of polling.