Skip to main content
An image is the blueprint for a sandbox: the software and files it starts with. Start from a built-in image, such as Base Image with Python, or create a custom image that packages the dependencies and starting files your agent needs every time. For what an image contains and how versions work, see How sandbox images work.

Prerequisites

  • Permission to create resources in your team.
  • For the CLI procedures, the Baseten CLI, signed in.

Choose a built-in image

The image catalog lists built-in environments for languages, browsers, web applications, and desktops, plus the custom images built by teams you can access. Each image has an Image reference, such as baseten/base-image:latest, that you use to create a sandbox.
To choose a built-in image:
  1. Sign in to your workspace at app.baseten.co and choose Sandboxes in the sidebar.
  2. Choose Create sandbox.
  3. To narrow the catalog, type a runtime or image name in Search images, or select a workload under Category. Clear category filters to include Base Image, which has no category.
  4. Choose an image card, then review its Image, Default memory, and Ports.

Create a custom image

A custom image packages the dependencies and starting files your tasks need. Build one from a Dockerfile with the CLI, use an SDK’s ImageBuilder, or import an image from a registry. Base Image includes wget, but it doesn’t include curl. Install any additional tools your task needs in a custom image. To build a custom image:
  1. Run the following commands to set a new image name and create a build directory:
  2. Create a Dockerfile. A sandbox image must include the sandbox API server and start it as the entrypoint, so copy it from the sandbox API image. This example starts from the same base as Base Image (Alpine Linux with Node.js, Python, Git, and Bash) and adds a package and a starting file. Run the following commands to create the Dockerfile and starting file:
  3. Keep credentials out of the build directory. Run the following command to push the directory and wait for the image to build:
  4. Run the following commands to create a sandbox from the image and check its installed tools and starting file:

Build with an SDK

An ImageBuilder creates a Dockerfile and its build context. It adds the sandbox API binary and entrypoint unless you supply them yourself. Set up your SDK and API key before running the code.
To build and check a custom image:Run the following code:
Pass my-image:latest to the SDK. The catalog shows the same custom image as sandbox/my-image:latest. The push call waits until the image is BUILT. The command then prints hello from the image, confirming that the sandbox contains the starting file. The examples then delete the test sandbox and keep the image for future sandboxes. If a request fails after creating image-check, delete the sandbox before running the code again. Delete my-image separately if you no longer need it.
For repeatable builds, pin the sandbox API image to a tested tag or digest instead of ghcr.io/blaxel-ai/sandbox:latest. Set the reference in a Dockerfile’s COPY --from, or use sandbox_api_image with Python’s from_registry(), sandboxApiImage with TypeScript’s fromRegistry(), or SandboxAPIImage with Go’s NewImageBuilderWithOptions().

Import an image from a registry

To import an image from a registry:
  1. Set a new repository name and the source image’s full registry reference, including the registry hostname. The source image must include and start the sandbox API server, as the built-in images do. Run the following commands to set the image name and registry reference:
  2. Run the following command to import the image:
    The CLI returns once the import is accepted. To wait for the import to finish, run the following command:
    To import from a private registry, run the following command with a Docker config.json containing the registry credentials:

List images

Check a custom image’s build status before using it. The Images tab and baseten sandbox image list list only your team’s custom images, not built-in images.
To list your team’s images:
  1. In Sandboxes, choose Images.
  2. For Find by image name or tag, type the image name.
  3. Review the matching row’s Latest size, Sandboxes, Updated, and Status values.
For a failed build, see the image build logs.

List versions

List an image’s version tags to choose which version a sandbox uses. Baseten assigns the tags; you can’t set or rename them.
To list an image’s versions:
  1. In Sandboxes > Images, choose the image.
  2. On Overview, review each version’s Tag, Size, Created, and Updated values in the tags table.
To use a version, select its tag in the image reference.

Add a version

Push changed source to an existing image name to add a version. Pushing identical source doesn’t create a version, and existing versions stay available. To add a version:
  1. Run baseten sandbox image push again with the same IMAGE_NAME, following Create a custom image.
  2. List the image’s versions and confirm a new tag appears.
If pushes to the same image name overlap, its status doesn’t identify which build finished. Use a separate image name to track a build independently.

Use an image in a sandbox

Create a sandbox in the team that owns the custom image. Choose the image in the dashboard, or run the following command:
The catalog uses latest when you select a custom image. This tag tracks the newest version and doesn’t appear in the version list. To keep new sandboxes on one version, choose a tag from List versions and replace latest in the image reference with that tag, such as sandbox/<IMAGE_NAME>:<TAG_NAME>. Sandboxes already using a specific tag keep their version.

Delete an image or a version

Deleting a sandbox leaves its image available. Delete the image or individual versions separately when you no longer need them.
Deleting an image removes all its versions. Delete a single tag to remove only that version.
Deletion fails while an active sandbox uses the image or version. Save the files you need, delete those sandboxes, and wait for them to terminate before retrying.
To delete a version:
  1. In Sandboxes > Images, choose the image.
  2. In the tags table, open the actions menu on the version’s row.
  3. Choose Delete tag, then choose Delete tag again to confirm.
To delete an image:
  1. In Sandboxes > Images, open the actions menu on the image’s row.
  2. Choose Delete image.
  3. Type the image’s name, then choose Delete image.
Delete image is unavailable while any sandbox uses the image.
Clean up unused images removes unused versions across the team, including ones kept for future sandboxes. Delete a specific image or tag when you want to choose what to remove.