Baseten Sandboxes are now available and free to use until November 16. Each organization can run up to 10 sandboxes at once. To raise this limit, contact support.
Choose memory and vCPUs
Set a sandbox’s memory, and Baseten gives it the matching number of vCPUs. Without a memory value, a sandbox gets 4,096 MiB and 2 vCPUs.
Each account has a maximum memory and vCPU count per sandbox. A request above
either returns HTTP
429 with the limit, such as
You have reached the maximum memory (4096) for your account. To raise your
limits, Contact us.
To create a sandbox with 2 GiB of memory:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code. The sandbox gets 1 vCPU:
Set a custom CPU count
Most workloads should keep the vCPU count that matches their memory. Set a CPU count when a workload needs a different balance, such as a compile-heavy task that needs more vCPUs than its memory provides. The CPU count is a whole number from 1 to 32, and memory must be 1,024 to 8,192 MiB per vCPU. For example, 4 vCPUs allow 4,096 to 32,768 MiB. Set memory along with the CPU count: with only a CPU count, memory defaults to 8,192 MiB per vCPU, capped at your account’s memory limit. To create a sandbox with 2 vCPUs and 2 GiB of memory:- TypeScript
- Python
- Go
- API
- CLI
- UI
Run the following code:
400 with the allowed
range, such as for 8 vCPU, memory must be between 8192 and 65536 MB. The
sandbox’s record shows its vCPU count as cpu.
To delete the sandbox automatically, set an
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 when you create a sandbox, or replace them later. 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.- TypeScript
- Python
- Go
- API
- CLI
- UI
To create a sandbox with environment variables:Run the following code:Set
secret: false for a value you want to read back later.**** when you read them back. For
configuration you’ll want to see later, such as LOG_LEVEL or
OUTPUT_FORMAT, mark the value as not secret so it stays readable.
Run the following command to read the sandbox’s environment variables back:
--plain-env
or secret: false for credentials; those values remain readable in ordinary
configuration responses.
Replace environment variables
An update that includes environment variables replaces the sandbox’s entire set, and removes any variable you omit. Include every variable you want to keep, including existing secrets with their actual values. Don’t copy masked**** values from a configuration response. An update without environment
variables leaves the existing set unchanged.
Set DB_PASSWORD in your local shell before running these examples.
To replace a sandbox’s environment variables:
- TypeScript
- Python
- Go
- API
- CLI
Run the following code:
Change sandbox labels
Labels help you find and group sandboxes, such as marking every sandbox an agent creates withpurpose=agent. A new set of labels replaces all previous
labels, so include every one you want to keep. This example changes the
purpose label from hello-world to hello-universe.
- TypeScript
- Python
- Go
- API
- CLI
- UI
To change sandbox labels:Run the following code:
Select a team
If you belong to one team, sandbox requests use it. If you belong to more than one, select the team that owns the sandbox in every request that manages it. To select a team:- TypeScript
- Python
- Go
- API
- CLI
Replace
<TEAM_ID> with your team’s ID, then configure the client as
follows: