# Automate an Android phone from Python.

Run `pip install mobilebox` and set your key. Then `create_phone()` gives your script or AI agent a ready cloud Android phone: your code reads its screen as text, taps, types, installs your APK and takes screenshots. In our 22 November 2026 benchmark a new phone was ready for its first screenshot in 1.35 s. It costs $0.01 a minute, billed per second after the first minute, and `platform="ios"` gives you an iPhone simulator for $0.03 a minute.

[Start a phone](https://mobilebox.dev/signup?device=android_cloud&amp;via=need-python&via=md) [Python client reference](https://mobilebox.dev/docs/reference?via=md#python-client)

Sign up with GitHub, Google or email. New workspaces get free credit, no card.

## One pull-request check, start to finish.

Start a phone, install the build, walk one step of the flow, keep the picture and delete the phone. The `finally` block deletes the phone even when a step fails, so nothing keeps running.

[The full pull-request check, as we ran it](https://mobilebox.dev/blog/android-phone-for-python-ai-agent?via=md)

```
# pip install mobilebox; MOBILESANDBOX_API_KEY=... python check.py
from mobilebox import Mobilebox

mb = Mobilebox()  # reads MOBILESANDBOX_API_KEY
phone = mb.create_phone(name="checkout-check", max_duration=600)
try:
    mb.install_app(phone.id, file="app.apk")
    result = mb.act(phone.id, [
        {"type": "open_app", "package": "com.example.shop"},
        {"type": "tap", "target": {"text": "Sign in"}},
        {"type": "wait_for", "text": "Welcome"},
    ])
    with open("signed-in.png", "wb") as f:
        f.write(mb.screenshot(phone.id))
    print("ok" if result.ok else result.error)
finally:
    mb.delete_phone(phone.id)
```

## What your code calls

Each method is one call to the REST API, so anything your script does, your agent can do over MCP as well.

| Method | What it does |
| --- | --- |
| create_phone() | A cloud Android phone, ready; platform="ios" for an iPhone, city="Berlin" for GPS, time zone and language there |
| install_app() | Your APK, .apks or .xapk from a file or a URL, or a simulator build on an iPhone |
| observe() | The screen as text and numbered elements; screen.find("Pay") returns one |
| act() | Tap, type, swipe, open apps and URLs, wait for text: up to 20 actions, stopping at the first failure |
| screenshot() | PNG bytes, for your CI artifacts or the pull request |
| park_phone(), start_phone() | Park keeps the apps, data and logins at no cost; start picks up where it left off |

Python 3.10 or newer, no other dependencies. For an agent framework, `pip install langchain-mobilebox` gives LangChain and LangGraph the phone as tools; [OpenAI Agents SDK](https://mobilebox.dev/integrations/openai-agents?via=md), [CrewAI](https://mobilebox.dev/integrations/crewai?via=md) and [browser-use](https://mobilebox.dev/integrations/browser-use?via=md) have their own pages.

## Questions

Android automation from Python.

Is there a Python package for Android automation?

Yes, it's `pip install mobilebox`. `create_phone()` gives you a cloud Android phone, and `observe`, `act`, `install_app` and `screenshot` drive it. $0.01 a minute, billed per second.

Do I need ADB, Appium or a local emulator?

No. The phone runs in the Mobilebox cloud and your Python code talks to it over HTTPS, from a laptop, a CI runner or a container without KVM.

Can my Python AI agent drive the phone?

Yes. Give the model `observe` and `act` as tools, or use `langchain-mobilebox` for LangChain and LangGraph. The [LangGraph page](https://mobilebox.dev/integrations/langgraph?via=md) has a complete program; when we ran it against production, it answered in 34 seconds.

Can I run many phones at once?

Yes, one `create_phone()` per task, with `idempotency_key=` so a retried job doesn't start a second phone. 50 Android phones for 10 minutes cost $5.00; see [phones in parallel](https://mobilebox.dev/blog/run-android-phones-in-parallel?via=md).

What does a run cost?

$0.01 a minute while the phone is ready, billed per second with a one-minute minimum; boot time is free. A 3-minute check on 100 pull requests a month costs $3 in phones.

Can the same code drive an iPhone?

Yes. `create_phone(platform="ios")` gives you an iPhone simulator, `model="ipad"` an iPad, at $0.03 a minute, with the same `observe` and `act`.

## Read more

[Python Android automation for AI agents Control a cloud Android phone from Python: pip install mobilebox, then one cloud phone per pull request: start it, install the build, walk the flow, screenshot each step, delete it. A tested script, the LangGraph version and what a run costs. Guides4 min read](https://mobilebox.dev/blog/android-phone-for-python-ai-agent?via=md) [How many Android emulators can run in parallel in CI? Local emulators in parallel compete for one runner’s KVM, CPU and memory. Create one cloud phone per task with one call each, give each an idempotency key, run the agents side by side and park or delete every phone in finally. What 50 phones cost. Guides3 min read](https://mobilebox.dev/blog/run-android-phones-in-parallel?via=md)

## Try it in your agent in 60 seconds

Paste this into Claude Code, Cursor, Codex or any agent that can read a web page. It asks for your email, gets its own key at once and adds the phone tools; the 6-digit code from your inbox keeps the workspace.

```
Set up Mobilebox for me: read https://mobilebox.dev/setup.md?via=python-android-automation and follow it.
```

[What your agent reads](https://mobilebox.dev/setup.md?via=python-android-automation)

## Next questions

- [Is there a Python package?](https://mobilebox.dev/blog/android-phone-for-python-ai-agent?via=next-python)

- [Does my agent need a real device?](https://mobilebox.dev/blog/real-android-devices-vs-cloud-phones?via=next-real-device)

- [Can my agent automate tasks in my apps?](https://mobilebox.dev/app-automation?via=next-automation)

- [What replaces Firebase Test Lab?](https://mobilebox.dev/blog/mobilebox-vs-firebase-test-lab?via=next-firebase)

- [Mobilebox or BrowserStack?](https://mobilebox.dev/blog/mobilebox-vs-browserstack?via=next-browserstack)

- [Cloud phone or a local emulator?](https://mobilebox.dev/blog/mobilebox-vs-local-emulator?via=next-emulator)

- [Limrun or Mobilebox?](https://mobilebox.dev/blog/mobilebox-vs-limrun?via=next-limrun)

- [How do I add it to Cursor, Codex or VS Code?](https://mobilebox.dev/blog/android-mcp-cursor-codex-vscode?via=next-setup)
