Set up
Install the CLI or an SDK:- CLI
- Python
- Go
- TypeScript
$SANDBOX_NAME for the sandbox name:
Sandbox commands are in pre-release. Arguments, flags, and output may change.
Create a sandbox
Creating a sandbox starts an isolated environment from an image. The new sandbox gets a name, an image, memory (which also sets its CPU allocation), and a region. Name, image, memory, and region can’t change after creation.- UI
- CLI
- Python
- Go
- TypeScript
To create a sandbox:
- Sign in to your workspace at app.baseten.co and choose Sandboxes in the sidebar.
- Choose Create sandbox.
- Choose Base Image, or another image with the software your task needs.
- Enter a Name, for example,
hello-world. - For Memory (MiB), keep the default or enter the memory the workload needs. More memory also means more CPU.
- Choose a Region.
- Optionally, for Time to live, choose how long the sandbox can run before Baseten deletes it.
- If the form shows Team, choose the team that should own the sandbox.
- Optionally, add environment variables.
- Choose Create sandbox.
Get a sandbox
A sandbox’s record shows its configuration, URL, and current status.- UI
- CLI
- Python
- Go
- TypeScript
In Sandboxes, choose the sandbox. Its detail page shows the same
status.
FAILED, inspect the sandbox’s logs
before retrying. For the deployment and deletion statuses, see
Lifecycle and expiration.
Run commands in a sandbox
Run a single command in a deployed sandbox. Its output streams to your terminal, and its exit code becomes the command’s exit code.- CLI
- Python
- Go
- TypeScript
Put the command after To set extra environment variables for one command, add To open an interactive terminal in the sandbox, like SSH, run:Press Ctrl+D to disconnect.
--:--env KEY=VALUE
before --:Set environment variables
Environment variables pass configuration, such as an output format or log level, to the processes in a sandbox, so one image can serve different tasks. Set them at creation. Names begin with a letter or underscore and contain only letters, digits, and underscores. Don’t put your Baseten API key in a sandbox’s environment.- UI
- CLI
- Python
- Go
- TypeScript
To set environment variables:
- In Sandboxes, choose Create sandbox, then choose an image.
- Under Environment variables, choose Add variable.
- Type a name and value, such as
OUTPUT_FORMATandjson. - Repeat steps 2 and 3 for each additional variable.
List sandboxes
- CLI
- Python
- Go
- TypeScript
--status or search names and labels with --query:Manage a sandbox’s labels
Labels help you find and group sandboxes, such as marking every sandbox an agent creates withpurpose=agent. This example changes the purpose label
from hello-world to hello-universe:
- UI
- CLI
- Python
- Go
- TypeScript
To change a sandbox’s labels:
- In Sandboxes, choose the sandbox.
- Choose Sandbox settings.
- Under Labels, add, change, or remove labels.
- Choose Save changes.
envs.
The name, image, memory, and region can’t change after creation. To use a
different image, create a new sandbox.
Delete a sandbox
Deletion stops the sandbox’s processes and permanently removes its files, so save the files you need first.- UI
- CLI
- Python
- Go
- TypeScript
To delete a sandbox:
- In Sandboxes, choose the sandbox.
- Choose Delete sandbox.
- Type the sandbox’s name to confirm, then choose Delete sandbox.
TERMINATED.
The sandbox reports TERMINATED for a few minutes, and then it’s no longer
found. Don’t reuse the name until deletion completes.
Work in a team
Sandbox commands act in your team. If you belong to more than one, name the team on each call:- CLI
- Python
- Go
- TypeScript
baseten org team list to see your teams, and use the same team
throughout a workflow.Handle a failed command
Use the error message to choose the next action:Next steps
Sandbox lifecycle and expiration
Track deployment status and set an expiration policy.
Manage sandbox images
Choose a built-in image, or create and version your own.