Amp bills agent usage to your Amp account. The free Hobby tier includes no usage, so buy credits or pick a paid tier (pricing) before you run the agent. To bill your own provider instead, set up model routing.
Via the console
- Go to console.superserve.ai and click Create sandbox.
-
Pick the
superserve/node-22template. -
Under Advanced Options → Environment Variables, add
AMP_API_KEYand paste your Amp access token (it starts withsgamp_). -
Create the sandbox, open its Terminal, and run:
Via the SDK
AMP_API_KEY from the environment. Environment variables are plain text, so any process in the sandbox, including the agent, can read the token. Revoke it on the access token page if it leaks.
Open the sandbox in the console, launch the terminal, and run amp.
Run headless
Pass a prompt with-x (execute mode). Amp runs it in the sandbox, prints its final message, and exits. Amp doesn’t ask for approval before it runs tools, so the agent runs shell commands and edits files without stopping.
Auto-approved commands stay inside the sandbox and can’t touch your machine, but the sandbox can still reach the internet. Use network rules to limit where it can connect.
--stream-json to get one JSON event per line instead of only the final message. The last event has type: "result" and the thread ID in session_id. If the turn succeeds, the final answer is in result. If it fails, is_error is true and the message is in error. Check is_error, because Amp can exit with code 0 when a turn fails. Check the command result before you parse: at the timeout, run() stops Amp and returns exit code 124, and truncated is true when the output was cut off. In both cases the last event can be missing or incomplete.
Continue a thread
Amp saves each conversation as a thread. Pass the thread ID toamp threads continue to send a follow-up with the earlier context. Amp archives a thread that -x creates when the command finishes, and an archived thread can’t be continued. Pass --no-archive-after-execute on the first turn, as the --stream-json example above does.
Keep the version fixed
Amp updates itself in the background, so a long-lived or resumed sandbox can end up on a newer version than the one you installed. SetAMP_SKIP_UPDATE_CHECK=1 to turn off update checks: