Skip to main content
The amp template supports AMP_API_KEY.

Run Amp

Create a sandbox from the amp template, run Amp headlessly, and clean up. The SDK and CLI paths are equivalent — use the one that matches your workflow.
import os
from nullspace import Sandbox

with Sandbox.create(
    template="amp",
    envs={"AMP_API_KEY": os.environ["AMP_API_KEY"]},
    timeout=600,
) as sandbox:
    result = sandbox.commands.run(
        'amp --dangerously-allow-all -x "Create a hello world HTTP server in Go"',
        shell=True,
        cwd="/workspace",
        timeout=600,
    )
    print(result.stdout)

Interactive terminal

Open a PTY instead of a headless run to drive Amp interactively:
nullspace sandbox pty create sb_123 --cols 120 --rows 30
nullspace sandbox pty connect sb_123 --session-id ses_123
# then, inside the PTY:
amp
Use the session_id from sandbox pty create with --session-id.

Work on a cloned repository

sandbox.git.clone("https://github.com/your-org/your-repo.git", path="/workspace/repo", depth=1)
sandbox.commands.run(
    'amp --dangerously-allow-all -x "Add error handling to all API endpoints"',
    shell=True,
    cwd="/workspace/repo",
    timeout=600,
    on_stdout=lambda data: print(data, end=""),
)
print(sandbox.git.diff(path="/workspace/repo"))

Streaming JSON

sandbox.commands.run(
    'amp --dangerously-allow-all --stream-json -x "Find and fix TODO comments"',
    shell=True,
    cwd="/workspace/repo",
    timeout=600,
    on_stdout=lambda data: print(data, end=""),
)

Thread continuation

Amp manages threads through its CLI. Keep the sandbox alive when you want to continue a thread with follow-up tasks, then inspect the resulting diff through sandbox.git.diff().