How to Connect an AI Agent to a Real iPhone: Screenshots, Actions and Feedback
Build an observe–act–verify interface for a vision agent using iRemotech screenshots and input actions. Includes a locally tested Python adapter and clear verification limits.

An agent that operates an iPhone needs two things from the outside world: a view of the current screen, and a way to touch it. On a remote physical iPhone both are ordinary HTTP calls — a JPEG from a snapshot route, a JSON body to an actions route, and a second look at the screen that says whether the first attempt worked. Everything in between is yours to write.
The iRemotech Device API supplies the device half of that loop: screenshots, taps, swipes, text entry and the rest of the action catalog over HTTPS, plus a live video stream and a live control channel for hands-on use. Everything above it — which model you call, what the agent may do, whether the task actually succeeded — stays in your application. Keeping that line sharp is what makes the integration small; blur it and you end up debugging a model and a phone at the same time.
The workflows that fit are step-by-step ones with a visible end state: reaching a settings screen, walking through a signup sequence, reproducing a support case on a known build. A real handset provides a physical iOS execution environment rather than a browser profile. Whether it reproduces a customer's experience still depends on the app, account, device and settings. It is not a measuring instrument for touch response, animation timing or game performance, and nothing here is a latency benchmark.
Keep the model outside the device adapter
Four parts, one responsibility each:
- Observation: fetch a snapshot of the current screen.
- Decision: hand the image and the task context to a vision-capable model.
- Execution: check the proposed action and send one approved command.
- Verification: observe again, then continue, stop or hand over to a person.
The adapter stays thin: it knows the routes, the auth header and the coordinate space, and nothing about intent. The model sees pixels and returns numbers; it never holds the key. Your host application decides which devices the agent can reach, which actions are allowed and what evidence counts as done.
A vision model needs no accessibility tree to get started, which lowers the entry cost — no per-app element maps to maintain and no private frameworks to hook. The trade-off is that the model is reading a picture, and pictures are ambiguous at the edges: half-loaded views, sheets still sliding in, low-contrast labels. Treat a proposed coordinate as a hypothesis that the next observation has to confirm, not as a fact.
Prepare an assigned device and a device API key
Create the key in the dashboard under API Access; the API documentation lists what each scope grants. Discovery and screenshots need read; input needs control. A content-publishing key is a different credential with a different job, and a key's scopes cannot be edited after creation — if you need control, issue a key that includes it.
Then ask what the key can reach:
curl --fail-with-body https://api.iremotech.com/v1/devices \
-H "Authorization: Bearer $IREMOTECH_DEVICE_API_KEY"
Take the public_id of a device that is assigned to this workflow and store it as IREMOTECH_DEVICE_ID. Do not grab the first entry in the list: on a shared fleet that handset may be in the middle of someone else's session right now.
Keep the key on the server, in the environment of the process that makes the calls — out of prompts, out of screenshots, out of any client that ships to a user.
One check before writing code: confirm the app and the account you intend to drive are actually on that phone and signed in as you expect. Installation and login state must be established through a supported workflow; the screenshot endpoint does not establish them for you.
A minimal observe-and-tap client
The client below does deliberately little: it observes, and it taps one approved point inside the frame it just observed. Model selection, retry policy and task logic stay with the caller. Dependencies: python -m pip install requests Pillow.
Verification scope: this adapter has been exercised by local tests built on synthetic JPEG fixtures and checked against the published OpenAPI contract. No authenticated live-device run and no task-success benchmark is reported in this article. Exercise it on a device assigned to you before you depend on it.
"""Minimal iRemotech vision-agent adapter; no autonomous decisions."""
import io
import os
from urllib.parse import quote
import requests
from PIL import Image
class IPhoneAdapter:
def __init__(self, api_key, device_id, session=None):
if not api_key or not device_id:
raise ValueError("An API key and an assigned device ID are required")
self.url = "https://api.iremotech.com/v1/devices/" + quote(device_id, safe="")
self.http = session if session is not None else requests.Session()
self.headers = {"Authorization": "Bearer " + api_key}
def observe(self):
response = self.http.get(self.url + "/snapshot", headers=self.headers, timeout=30)
response.raise_for_status()
frame = response.content
with Image.open(io.BytesIO(frame)) as image:
if image.format != "JPEG":
raise ValueError("Expected a JPEG snapshot")
image.load()
size = image.size
return frame, size
def tap(self, x, y, size, *, approved=False):
if not approved:
raise PermissionError("The caller must approve the action")
width, height = size
if type(x) is not int or type(y) is not int:
raise ValueError("Coordinates must be integers")
if not (0 <= x < width and 0 <= y < height):
raise ValueError("Coordinates are outside the observed snapshot")
response = self.http.post(
self.url + "/actions",
headers=self.headers,
json={"type": "tap", "x": x, "y": y},
timeout=30,
)
response.raise_for_status()
return response.json()
if __name__ == "__main__":
from pathlib import Path
client = IPhoneAdapter(os.environ["IREMOTECH_DEVICE_API_KEY"], os.environ["IREMOTECH_DEVICE_ID"])
frame, size = client.observe()
Path("snapshot.jpg").write_bytes(frame)
print("Saved snapshot.jpg; dimensions:", size)
# Observation only. The program does not tap or type by default.
Run the file unchanged and it only observes: it writes snapshot.jpg and prints its dimensions. Putting it to work means handing that frame to your model, checking the point it proposes against the frame, and letting host policy decide whether the call becomes tap(x, y, size, approved=True).
Two details in the code deserve a closer look. approved is a tripwire against a careless call, not an authorization system — the real permission check belongs in the code that receives the model's proposal, because anything that can set the flag can also grant itself the permission. And the type(x) is not int test rejects booleans and floats as well as out-of-range values, which matters when a model returns 640.0 or True where an integer was expected.
The nine local tests sit on the boundary between this client and the API: JPEG decoding and rejection of a non-JPEG body, coordinate bounds including those type cases, the approval guard, request serialization for a tap, propagation of HTTP errors, a timeout that is not retried, missing credentials, and a contract check that the two routes and the tap schema still match the published OpenAPI file. What they cannot tell you is anything about the device — whether it is online, whether the app is where you think it is, whether the model picked a sensible point. That is what your own staging run has to answer.
Send snapshot pixels, not iPhone points
Coordinates live in the pixel space of the snapshot — the size of the JPEG the API just returned. Read the point straight off that image and send it unchanged; the API scales it onto the phone's logical canvas. The device detail response reports both sizes, snapshot in pixels (the coordinate space) and screen in iPhone points (informational, useful for sizing a panel in your own UI). Converting coordinates into screen can put an otherwise correct tap in the wrong place.
If you crop or downscale the frame to meet your chosen model’s image or cost constraints, invert that transform before sending anything. Keep the transform attached to the observation that produced it instead of recomputing it from the model's output.
Skipping the transform altogether is a legitimate first version: send the original frame and accept the token cost. Either way, take a fresh snapshot after anything that moves the layout — navigation, rotation, a keyboard sliding up. A point that was correct on the previous screen is just a number on the next one.
Close the loop on evidence
One observation, one action, one verification. After the tap, look at the new screen for the change you predicted — the next view, the switch that flipped, the sheet that should have opened — before issuing the following command.
A concrete shape: the task is "open Settings, then General, then report the iOS version shown". Each step is judged from the screen that follows it, never from the status code of the request that caused it. That difference is the whole gap between an agent that reports what it saw and one that reports what it hoped for.
Timeouts need their own rule, because a timed-out action is not a failed action. The command may have reached the phone and run after your client gave up; retrying it blindly can tap twice, submit a form twice or toggle a setting straight back. Observe again, compare the screen with the state you expected, and decide from there. Errors arrive as RFC 7807 problem documents with a stable code field, so branch on code and not on the human-readable detail, and honour Retry-After when a 429 comes back.
Budget the run in observations and steps, and write the stop conditions before the first attempt. Snapshots and actions count against the daily per-device budgets the API reports, which is a practical reason to observe with purpose rather than poll in a tight loop. An unrecognised screen, a verification prompt, a login wall or any request outside the approved task is a hand-off, not an invitation to improvise.
One operator per device, one record per run
A phone has a physical state, and usually more than one operator who can move it mid-task: someone on the dashboard, another agent or a scheduled job. Coordinate ownership of the device for the duration of the run and release it at the end; a queue or a lease in your own system is one way to prevent competing jobs from changing the same screen.
Finish with a short execution record: device, snapshots taken, actions approved, what the screen showed afterwards, and why the run stopped. Redact the key and anything sensitive on screen before the record reaches your logs. The outcome line comes from the last snapshot, not from the model's own account of its work.
For how hardware, access and control software divide the job in a phone farm, see what phone-farm software actually controls.
Where MCP fits
An MCP server is a tidy way to expose an adapter like this one as tools to an MCP-capable agent, and it is nothing more than that: a wrapper over the same HTTPS calls. It is optional, and it is not a prerequisite for using the API — the Python above talks to the API directly.
Get the observe–act–verify loop right first. If an MCP client is how your agent consumes tools, wrap the finished adapter and keep the permission checks, the device assignment and the step budget inside the wrapper. The same shape works for an internal service, a CLI or any other tool interface.
Start with one narrow workflow
The cheapest useful first project is one assigned phone, one known app and account state, and a task with discrete steps and an unambiguous visible result. Run it end to end, measure what it actually did, then decide whether a second workflow, a second device or an MCP wrapper has earned its place.
If your handsets already come from a managed fleet, this is a few dozen lines of client code on credentials you already hold — no device lab to build, no racks to keep, no shipping phones to whoever needs to see the screen. The Device API reference and the OpenAPI contract carry the current endpoints; prove one controlled workflow against them before you build a system around it.
Stop juggling physical devices.
iRemotech gives you real iPhones in the cloud — ready for multi-account operations, automation, and scale. Create your account in minutes.
Sign up freeMiguel Nogales
Founder @ iRemotech
From Spain, living in Andorra. Tech enthusiast passionate about infrastructure, remote technology, and building innovative solutions.