Skip to main content
Create a drive, check it, change its labels, or delete it. Create it in the region where the sandboxes that mount it run. To use the files from a sandbox, see Mount drives.
Drives are in pre-release in the Baseten CLI (baseten drive and baseten sandbox drive) and in the Python, TypeScript, and Go SDKs (baseten, @basetenlabs/client, @basetenlabs/sandbox, and baseten-go). Commands, methods, and responses can change. The Management API drive operations are experimental.

Set up

The drive examples use the same SDKs and CLI as sandboxes. The management client creates, gets, lists, updates, and deletes drives. Mounting goes through a sandbox. Every example reads your API key from the BASETEN_API_KEY environment variable, so keep the key out of your code. To set your API key: Replace <BASETEN_API_KEY> with a personal API key or a team API key with Full access to all team models. Other key types, such as Invoke dedicated models, can’t create the access token that drive requests use. The SDKs and CLI create that token for you. Then run the following command in the shell where you run the examples:
To install and connect your SDK or CLI:
  1. Run the following command to install the SDK:
  2. Create the management client, which reads the key from the environment:

Select a team

If you belong to one team, requests use it. If you belong to more than one, every drive request must name a team, or it fails. Pass the same team when you create the sandbox client. Create the drive in the team whose sandboxes mount it. Replace <TEAM_ID> with the team’s ID. Select a team shows how to find it for a sandbox. Use that same ID here. To pass the team:
Add teamId to each drive call, and pass it when you create the sandbox client:

Create a drive

You can’t change the name or region later. Creation returns before the drive is ready. The drive is ready when its status is DEPLOYED.
Each drive name is unique in your team. Use lowercase letters, digits, and hyphens, from 1 to 49 characters, and don’t start or end with a hyphen. If you don’t pass a name, Baseten generates one.
To create a drive named shared-notes:
Run the following code, which waits until the drive is ready:

Create a drive in a specific region

A drive defaults to your default sandbox region. Only sandboxes in the drive’s region can mount it, so create it in the region that your sandboxes run in. To create a drive in a specific region:
Run the following code. It prints the regions available to your account, then creates the drive in us-was-1. Replace us-was-1 with a name from the list.

Get a drive

A drive’s record holds its name, region, status, and labels, and when and by whom it was created and last updated. Its status is one of these values: To get the drive named shared-notes:
Run the following code:

List drives

Drives are listed newest first. The SDKs fetch further pages as you iterate. To list your team’s drives:
Run the following code:

Filter drives

Filter by a search over drive names, by status, or by both. The status values are DEPLOYING, DEPLOYED, FAILED, and DELETING, and you can pass more than one. To list drives with notes in their name that failed:
Run the following code:

Replace drive labels

Labels are the only part of a drive you can change. The labels you send replace the drive’s current labels. They aren’t merged with the labels already on it. To set the labels of shared-notes to project=alpha and env=dev:
Run the following code:
To remove every label, pass labels: {}.

Delete a drive

Delete a drive when no sandbox needs its files anymore.
Deleting a drive permanently deletes every file on it, for every sandbox that uses it. You can’t undo it.
Before you delete a drive, unmount it from every sandbox that has it mounted. Baseten doesn’t block deleting a drive that’s still mounted, and a sandbox that has it mounted keeps the mount after the drive is gone, still able to read and write there. Deletion continues after the call returns, and the drive’s status is DELETING until it’s gone. To delete the drive named shared-notes:
Run the following code:
The SDK examples print DELETING. To confirm the drive is gone, get the drive. Once it’s gone, the request returns HTTP 404.

Next steps

Mount drives

Mount the drive in a running sandbox.

Drives

Decide when a drive fits better than a sandbox volume.