Skip to main content
This tutorial shows you how to run Amp in a Blaxel sandbox. You will create a sandbox with Amp pre-installed, clone a repository, stream a coding task, and continue the same thread later.

Prerequisites

You need:
  • a Blaxel account;
  • the Blaxel CLI;
  • an Amp access token;
  • Node.js 24 or Python 3.10 or newer;
  • a Git repository that the sandbox can clone.
Log in to Blaxel:
Export your Amp token and repository URL:
The sandbox receives AMP_API_KEY as an environment variable. The example does not print it.
Headless Amp tasks can run commands without asking for confirmation. Use trusted repositories, private threads, a short sandbox TTL, and restricted network access for sensitive code.

1. Install the Blaxel SDK

Create a local project and install one Blaxel SDK:

2. Create the Amp sandbox

Create index.ts or main.py with the following code:
Run the script:
The blaxel/amp:latest image includes Amp, Git, and the Blaxel sandbox API. The sandbox keeps its memory and files when it enters standby.
createIfNotExists reuses a sandbox with the same name. Delete and recreate the sandbox after you rotate AMP_API_KEY.

3. Run an Amp task

Add the following code after sandbox creation and repository cloning. In Python, add it inside main().
Amp returns structured JSON lines while it works. Store the printed thread ID if you need to continue the task later.

4. Continue the thread after reconnecting

Your application can reconnect after the sandbox enters standby. Create continue.ts or continue.py with the following code. Replace the environment value with the thread ID from the first task.
Run the continuation script:
The sandbox wakes on the first process call. Its repository files and local Amp thread metadata remain available.

5. Open Amp in the sandbox terminal

Connect to the same sandbox when you want an interactive session:

6. Troubleshoot common failures

Amp rejects the access token

Confirm that AMP_API_KEY contains an active Amp access token. Delete and recreate an existing sandbox after you rotate the token.

The repository does not clone

Confirm that the sandbox can access the Git host. For a private repository, provide credentials through your approved secret workflow instead of placing them in the script.

Amp cannot reach a required service

Allow the domains required by Amp, your Git host, and your dependency registries in the sandbox network policy.

A task exits without a successful result

Check the final structured result event. Amp can report an error in the event stream, so do not rely only on the process exit code.

The thread does not continue

Reconnect to the same named sandbox and use the exact thread ID from the first task. A different sandbox does not contain the same repository state.

7. Delete the sandbox

Delete the sandbox when you finish:

Resources

Amp manual

Learn about Amp modes, threads, and command-line options.

Sandbox processes

Run and monitor more commands with Python or TypeScript.
Last modified on August 10, 2026