You never tell the SDK where it is. It checks, and adapts: where the session is cached, whether an agent has a disk to work on, whether bash exists at all. What follows is what changes, and what you have to supply when something is missing.
Detection
Three checks, in this order. The order matters: a Worker has neither process nor window.document, so it has to be identified on its own terms.
| Result | Recognised by |
|---|---|
| node | process.versions.node is a string |
| worker | navigator.userAgent is "Cloudflare-Workers" |
| browser | window.document exists |
| unknown | none of the above — the SDK still works over HTTP |
const api = new IaGenify({ apiKey });
api.env; // "node" | "worker" | "browser" | "unknown"
api.framework; // "node" | "next.js" | "gatsby" | "vite" | "browser"
api.capabilities; // { runtime, shell, filesystem, persistentStorage, http }api = IaGenify(api_key=api_key)
api.env # "python"
api.framework # "python"
api.capabilities # {"runtime", "shell", "filesystem", "persistentStorage", "http"}framework is a detail of where you are running, not a feature switch: it travels with the session so your own calls can be told apart later. capabilities is the one worth branching on.
What each one can do
| Node | Browser | Workers | |
|---|---|---|---|
| capabilities.filesystem | true | false | false |
| capabilities.shell | true | false | false |
| capabilities.persistentStorage | true | true | false |
| capabilities.http | true | true | true |
| Session cache | a file | localStorage | memory |
| Agent workspace | on disk | supply files | supply files |
| bash | yes | supply shell | supply shell |
| Terminals | yes | no | no |
An agent that cannot reach a workspace refuses at construction and names what is missing, so the failure arrives before the run rather than inside it.
Branching on it
// The same code path, wherever it runs
const machine = api.capabilities.filesystem
? await api.storage.get() // this computer
: await api.storage.device({ deviceId }); // a browser device
const agent = api.agents.create({
runtime: "local",
machine,
model: "gemini-3.5-flash",
// Only needed where there is no disk; harmless to pass when there is one
...(api.capabilities.filesystem ? {} : { files: myFileBridge }),
});# The same code path, wherever it runs
machine = (
api.storage.get() # this computer
if api.capabilities["filesystem"]
else api.storage.device(device_id=device_id) # a browser device
)
agent = api.agents.create(
runtime="local",
machine=machine,
model="gemini-3.5-flash",
# Only needed where there is no disk; harmless to pass when there is one
**({} if api.capabilities["filesystem"] else {"files": my_file_bridge}),
)The machine id
Every runtime computes one and caches it for the process. It is a hash of machine facts — hostname, platform, architecture, runtime string — and never of anything you typed. It travels on every request as X-IaGenify-Machine-Id, and it is what lets a machine appear as a storage on your account instead of being anonymous.
// What it is built from, per runtime
node { os: "win32", arch: "x64", hostname: "DESKTOP-7F", runtime: "node v22.4.0" }
browser { os: navigator.platform, arch: "unknown", hostname: location.hostname, runtime: userAgent }
worker { os: "cloudflare", arch: "unknown", hostname: "unknown", runtime: "cloudflare-workers" }# What it is built from in Python
import platform, socket
environment = {
"os": platform.system().lower(), # "windows", "linux", "darwin"
"arch": platform.machine(), # "AMD64", "x86_64", "arm64"
"hostname": socket.gethostname(),
"runtime": f"python {platform.python_version()}",
}Reported resources
Each request carries an X-IaGenify-Resources header, recomputed at most every 30 seconds. Every probe is wrapped: when one is unavailable the field is left out rather than failing the call, so the header is a best effort and never a reason for an error.
// node
{ cpu: { model, cores, speedMHz },
memory: { totalBytes, freeBytes },
gpu: [{ model, vramBytes }], // only when a GPU probe answers
disk: [{ mount, totalBytes, freeBytes }] }
// browser
{ cpu: { logicalCores }, // navigator.hardwareConcurrency
memory: { totalGb }, // only where deviceMemory exists
gpu: [{ model }], // only if an adapter is granted
storage: { quotaBytes, usageBytes } }
// worker
{ runtime: "cloudflare-workers" }# What a Python process reports
{"cpu": {"model": ..., "cores": ...},
"memory": {"totalBytes": ..., "freeBytes": ...},
"disk": [{"mount": ..., "totalBytes": ..., "freeBytes": ...}]}Choosing where to run
| You want | Run it in |
|---|---|
| An agent that works on real files, or runs commands | Node |
| A low-latency endpoint close to the user | Workers |
| An agent working on a visitor's own device | Node, with a files bridge to the browser |
| A key that never leaves your control | Node or Workers — never the browser |