Skip to main content
Create a sandbox and run code with the Python or TypeScript SDK. The client defaults to AWS us-east-1 and the base-small template. The same calls from a shell are on Use the CLI.

Install the SDK

Set an API key

Create an API key in the console, then set it in your environment:
Or pass it when constructing the client:
Create the key in the Quickstart. It is shown once.

Choose a region

Set cloud and region on the client, not on runtime.create(). The create call below uses the defaults.
GRAVIXLAYER_CLOUD and GRAVIXLAYER_REGION override the client. Regions are listed under Multi-Cloud Support. REST create still accepts cloud and region in the body; the SDKs fill those fields from the client.

Create a sandbox

More create options: Create Runtime.

Run code

Every run_code / runCode call returns structured output (text, success, and optional error details).
JavaScript and persistent contexts: Run code.

Run a command

Use run_cmd / runCmd for shell commands. Pass a single string, or a command plus args.
Install packages and scripts: Run Command.

Read and write a file

Use sandbox.file (not files).
Full file API: Write File, Read File.

List and terminate runtimes

Python and TypeScript

Always call kill() when you are finished.

Next

Quickstart

Secrets, network policies, and a fuller walkthrough

Use the CLI

Install the CLI and manage sandboxes from your terminal

Snapshots

Checkpoint a runtime and create more from it

Templates

Base sizes and custom template builds

How a runtime works

What is inside a sandbox, and how long it stays up