Runtime environments
An environment is the recipe for a session’s machine: which sandbox template, which packages are preinstalled and which networks it can reach. Each session of a service agent gets a fresh machine built from the environment. Bash, file access, skill installation and codemode all happen on that machine.
You need Bun or Node.js with native fetch and an API Key for your organization. Set PRAXIS_API_KEY in the server process.
Built-in environments and defaults
GET /agent/v1/environments returns the built-in environment first. It is read-only; changing or archiving it returns 409:
| id | Networking | Notes |
|---|---|---|
node22 | unrestricted | The default for new agents and for sessions that name no environment. Actually runs Node.js 24; node22 is a name kept for compatibility |
A custom environment that omits networking is unrestricted. Say limited explicitly when you want a restriction.
Create an environment
POST /agent/v1/environments. config.type must be cloud (self_hosted is not supported and returns 400):
{ "name": "Python with cowsay", "config": { "type": "cloud", "template": "base-large", "packages": { "pip": ["cowsay==6.1"] }, "networking": { "type": "limited", "allow_package_managers": true, "allowed_hosts": ["example.com"] } }}Template
config.template selects the sandbox template. Size is part of the name; there is no separate size field. Omit it, or send null, for the default node22. An unknown name returns 400 on create and on update, and lists the options:
config.template does-not-exist-tpl is not an available template; available: base, base-large, base-small, browser, data, document, media, node22A template can also be the name or sbe_ ID of one of your own ready sandbox environments.
Packages
config.packages is grouped by package manager: apt, pip, npm, cargo, gem, go, up to 100 each. Only a bare name (installs the latest) or an exact pin is accepted; range syntax returns 400:
| Manager | Pinned form | Example |
|---|---|---|
pip | name==version | cowsay==6.1 |
npm | name@x.y.z | lodash@4.17.21, @scope/pkg@1.2.3 |
cargo, gem | name@version | serde_json@1.0.120 |
go | module/path@version | github.com/google/uuid@v1.6.0 |
apt | name=version | jq=1.6-2.1 |
requests>=2 and lodash@^4 return Invalid pip package name / Invalid npm package name: use an exact version. Packages are installed when the session’s sandbox is created. A failed install terminates the session with ENVIRONMENT_PACKAGE_INSTALL_FAILED. You are responsible for the package and version existing; creating the environment does not check.
Networking
networking.type | Meaning |
|---|---|
unrestricted | Public internet allowed. Omitting networking on create gives this |
limited | Only allowed_hosts (up to 256 domains, optionally prefixed with *.) plus the hosts opened by the two switches below |
The two limited switches default to false. allow_package_managers opens public package registries (PyPI, npm and so on) and must be true when packages is set. allow_mcp_servers opens the MCP server hosts the agent declares. Network limits take effect when the sandbox is created.
Update, list and archive
POST /agent/v1/environments/{environment_id} updates: omitted fields keep their value, and sending only packages inside config keeps the existing networking. GET /agent/v1/environments hides archived environments unless you pass include_archived=true.
Archive with POST /agent/v1/environments/{environment_id}/archive. An archived environment cannot create new sessions. If the active version of a non-archived agent still uses it, archiving returns 409 RESOURCE_IN_USE and names those agents: point them at another environment first, then archive.
Make an agent use it
environment_id selects the environment. From highest to lowest priority:
environment_idon session creation;nullcounts as an explicit choice.environment_idin the agent’s active version, saved with the version like other settings (see Versions).- The built-in
node22.
environment_id: null means no machine. The session can only converse: no bash, no codemode, no skill installation, and bindings cannot take effect, so saving bindings together with null returns 400 (bindings need a machine). Keep the default environment when the agent needs data or platform services.
End-to-end example
The script creates an environment with cowsay==6.1, makes a new agent use it by default, and has the session prove the package is installed with bash. Save it as env-demo.mjs and run node env-demo.mjs.
import assert from "node:assert/strict";import { setTimeout as delay } from "node:timers/promises";
const { PRAXIS_API_KEY } = process.env;assert(PRAXIS_API_KEY, "Set PRAXIS_API_KEY in the server process");const base = "https://api.deepraxis.com/agent/v1";async function request(path, body) { const response = await fetch(`${base}${path}`, { method: body === undefined ? "GET" : "POST", headers: { Authorization: `Bearer ${PRAXIS_API_KEY}`, "Content-Type": "application/json" }, ...(body === undefined ? {} : { body: JSON.stringify(body) }), signal: AbortSignal.timeout(30_000), }); const result = await response.json(); if (!response.ok) { throw new Error(`HTTP ${response.status}; request=${response.headers.get("X-Request-Id")}; ${result.error?.message ?? ""}`); } return result;}
// 1. An environment with one pinned Python package. Networking is not set, so it is unrestricted.const environment = await request("/environments", { name: "Python with cowsay", config: { type: "cloud", packages: { pip: ["cowsay==6.1"] } },});assert(environment.id.startsWith("env_"));
// 2. An agent that starts every session in that environment.const agent = await request("/agents", { name: "Environment demo", kind: "service", model: "deepseek-flash", system: "Run shell commands when asked and report the exact output.", environment_id: environment.id,});assert.equal(agent.environment_id, environment.id);
// 3. Ask the session to prove the package is installed.const session = await request("/sessions", { agent: { type: "agent", id: agent.id, version: agent.version },});assert.equal(session.environment_id, environment.id);await request(`/sessions/${session.id}/events`, { events: [{ type: "user.message", content: [{ type: "text", text: "Run `pip show cowsay` with bash and tell me the Version line." }] }],});
const deadline = Date.now() + 240_000;let reply = "";while (Date.now() < deadline && !reply) { const { data } = await request(`/sessions/${session.id}/events?order=asc&limit=100`); const last = data.findLastIndex((event) => event.type === "agent.message"); if (last >= 0 && data.slice(last).some((event) => event.type === "session.status_idle")) { reply = data.filter((event) => event.type === "agent.message") .flatMap((event) => event.content ?? []).map((block) => block.text ?? "").join("\n"); } else await delay(2000);}assert(reply.includes("6.1"), `Expected version 6.1 in the reply, got: ${reply}`);console.log({ environment: environment.id, session: session.id, reply });Expected: the environment ID and session ID, and a reply containing Version: 6.1.
When it fails
| Symptom | What to do |
|---|---|
400 config.template … is not an available template | Pick one of the names the message lists |
400 Invalid pip package name / Invalid npm package name | Drop the range operator and use an exact == or @x.y.z version |
400 Invalid allowed_hosts | More than 256 hosts, or a value that is not a valid domain |
409 Built-in environments are read-only | node22 cannot be changed or archived; create your own |
409 RESOURCE_IN_USE (archive) | Point the agents named in the message at another environment_id first |
409 Environment is archived (create session) | The agent or session still points at an archived environment; update the agent |
Session ends with ENVIRONMENT_PACKAGE_INSTALL_FAILED | The package or version does not exist; under limited networking, installs need allow_package_managers: true, which is not checked when you save |
For every parameter see the Agent API. Next: Use skills · Configure your agent