1
Get an API key
Sign in or create an account, then create a cloud API key (
dr_sk_…). You do not need your own model key, but you can bring your own.
Export it for the examples:2
Install
MOBILERUN_API_KEY automatically.3
Run your first task
Create a device, run the task, print the answer, then stop the device.
4
Read the result
task.wait() returns the same response as GET /tasks/{id}/status: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. See
Agent configuration for more.See the task trajectory for the full record of screenshots and actions (GET /tasks/{id}/trajectory).Details
Run TypeScript as an ES module
Run TypeScript as an ES module
The TypeScript example uses top-level
await, so run it as an ES module. Set "type": "module" in
your package.json, or save it as quickstart.mts, and run it with npx tsx quickstart.ts (or
npx tsx quickstart.mts).Stop or terminate a device
Stop or terminate a device
This example uses pay as you go (
billing: 'minute'). Step 5 stops the device: it keeps its apps and data and uses no phone credits until you resume it, but still occupies a device slot. Call device.terminate() (Go: device.Terminate(ctx, mobilerun.DeviceTerminateParams{})) when you no longer need it. See Cloud Android to compare pay as you go with a monthly subscription.Cloud iOS devices cannot be stopped yet; call device.terminate() instead.Use an existing device
Use an existing device
Replace device creation with
await mobilerun.devices.get('DEVICE_ID') in TypeScript,
mobilerun.devices.get("DEVICE_ID") in Python, or client.Devices.Get(ctx, "DEVICE_ID") in Go. Remove the stop call if it should keep running.
See Mobilerun SDK for resuming devices and SDK helpers for all helpers.Handle a failed task
Handle a failed task
task.wait() returns the final status on completion. If the task fails or is cancelled, it throws
WaitFailureError in TypeScript or raises it in Python. In Go, task.Wait(ctx) returns a *sdk.WaitFailureError; check for it with errors.As.Choose a model
Choose a model
Pass
llmModel 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 the default, mobilerun/mobile-agent-fast.SDK and API reference
- Mobilerun SDK: devices, tasks, cleanup, and streaming.
- API reference: request and response schemas.
- Embed a device stream: add a live device to your app.
Automate it
Working with tasks
Configure the agent and read task results.
Routines
Turn repeatable work into routines.
Serverless Functions
Run code without managing a server.
Sandboxes
Run your automation in a sandbox.