Get an API key
Client

env · capabilities · framework

api.env · api.capabilities · api.framework

What the SDK decided about the place it is running. Three properties, read once at construction, and they are what the engine branches on.

read at constructionno I/Odetected, not configured
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

You cannot set these. They are detected, and they matter because they decide where a session is cached, whether an agent can run a command at all, and what the server is told about the caller.

env

ValueDetected from
nodeprocess.versions.node is a string
workerthe runtime identifies itself as a Cloudflare Worker
browserwindow.document exists
unknownnone of the above matched

The order matters: Node is tested first, then the worker, then the browser. So a bundler that shims process into a page makes that page answer node — and since env decides the session store, that is the first thing to read when caching behaves oddly in a bundled app.

console.log(api.env, api.framework, api.capabilities);
// "node" "next.js" { runtime: "node", shell: true, … }   ← server
// "browser" "next.js" { runtime: "browser", shell: false, … } ← page
print(api.env, api.framework, api.capabilities)
# "python" "python" {"runtime": "python", "shell": True, ...}

capabilities

{
  runtime: "node",
  shell: true,              // commands can be run here
  filesystem: true,         // files can be read and written here
  persistentStorage: true,  // a session survives a restart
  http: true                // always true
}
{
    "runtime": "python",
    "shell": True,               # commands can be run here
    "filesystem": True,          # files can be read and written here
    "persistentStorage": True,   # a session survives a restart
    "http": True,                # always True
}
Capabilitynodebrowserworker
shellyesnono
filesystemyesnono
persistentStorageyesyesno
httpyesyesyes

These describe the runtime, not a permission. Permission is a separate decision, made per call by your own callback — a runtime that can run commands still asks before it does. See Permissions.

What each one changes

CapabilityFalse means
shellNo bash tool, unless you supply a shell bridge.
filesystemNo workspace on this runtime; file tools need a files bridge.
persistentStorageThe session lives as long as the process, and is exchanged again after that.

A bridge is how a runtime without a capability gets the behaviour anyway: the tool call is relayed to somewhere that can run it, and the answer comes back. That is exactly how a phone — no shell, no filesystem — still reads files and runs commands. See Bridges.

const tools = api.capabilities.shell
  ? api.tools.all
  : api.tools.all.filter((name) => name !== "bash" && name !== "terminal");

const agent = api.agents.create({ runtime: "local", machine: pc, tools });
tools = (
    list(api.tools.all)
    if api.capabilities["shell"]
    else [name for name in api.tools.all if name not in ("bash", "terminal")]
)

agent = api.agents.create(runtime="local", machine=pc, model=model, tools=tools)

framework

ValueDetected from
next.jsthe page carries Next's own globals
gatsbythe page carries Gatsby's global
vitethe module URL names Vite
browsera page, and none of the above
nodethere is no window at all
A server runtime reads node here

Framework detection looks at the page. With no window — Node, and a Worker too — it answers node. Read env when you want the runtime; read framework only to learn which page framework is around you.

What of it reaches the server

The runtime and the framework travel with the key exchange, together with a machine id derived from the host's own name, platform, architecture and runtime version. Each later request carries that id and whatever resources could be detected.

What is sentWhy it exists
runtime and frameworkSo a session can be told apart from another on the same account.
machine idSo one machine is recognised across restarts instead of registered twice.
detected resourcesSo a machine storage can report its own disk, CPU and GPU.

Resource detection is best-effort and silent: anything it cannot read is simply absent, and nothing fails for it. The full list of headers, and how to print exactly what your process sends, is on Request headers.

Branching on it

if (!api.capabilities.persistentStorage) {
  // Nothing is cached between runs: each one exchanges the key once.
  // Supply a storage you control if you want the session to outlive the process.
}

if (api.env === "browser") {
  // A real key must not be here. Call your own server instead.
}

if (api.env === "unknown") {
  // An unrecognised runtime. HTTP works; assume nothing else does.
}
if not api.capabilities["persistentStorage"]:
    # Nothing is cached between runs: each one exchanges the key once.
    # Supply a storage you control if you want the session to outlive the process.
    pass

# A Python process is always a server or a script: a real key belongs here,
# never in the browser pages it serves.