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.
A sandbox’s memory and vCPUs set its price. See sandbox prices for the rates.
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:- API
- CLI
- UI
Run the following command:
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.
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.- 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.**** for values marked as secret. Masking is
on by default. Turn it off when you set a value you want to read back.
Run the following command to read the sandbox’s environment variables back:
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 with its actual value. Don’t copy masked**** values from a
configuration response. An update without environment variables leaves the
existing set unchanged.
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: