Skip to main content
Agent Sandbox provides official SDKs for application code in Python and Node.js. This page goes from an API key to a program that creates a sandbox, runs code inside it, and lists files in the sandbox filesystem.
Requirements: Python 3.10+ or Node.js 20+.

Set up and run the example

1

Create an API key

Open the API Keys page of the console and select Add New Key. Keep the key for the environment setup step.
2

Install the SDK

Install the package for the language the example runs in.
3

Set environment variables

Set two environment variables before running any example. Replace <your-api-key> with a key from the API Keys page of the console.
The SDK and the CLI read both variables from the environment.
string
Authenticates requests to Agent Sandbox.
string
Selects the Agent Sandbox service for ppio.ai. Without it, the SDK and the CLI connect to their built-in default service instead.
These commands set the variables for the current terminal session only.
4

Run the example

The program creates a sandbox, runs one line of Python inside it, and lists the entries under /tmp. Save it as main.py or index.mts, then run the saved file.
5

Clean up

Close the sandbox when it is no longer needed. Both examples do this by calling kill() in a finally block.
A finished run prints the execution logs, which contain hello world, followed by the entries under /tmp.

Next steps

Create a sandbox

Choose a template and set the timeout, environment variables and metadata.

Agent Sandbox overview

Learn the core concepts: sandboxes, templates and snapshots.
Last modified on November 19, 2026