Via the console
- On the Secrets page, create a secret with the Anthropic provider and paste your API key — you only do this once, and the key never enters the sandbox.
- Go to console.superserve.ai and click Create sandbox.
-
Pick the
superserve/node-22template. -
Under Advanced Options → Secrets, bind that secret to
ANTHROPIC_API_KEY. -
Create the sandbox, open its Terminal, and run:
Via the SDK
ANTHROPIC_API_KEY as usual, but its value is a stand-in token — the real key is attached only on requests to Anthropic, never exposed to the agent.
Open the sandbox in the console, launch the terminal, and run pi.
Run headless
Pass a prompt with-p (print mode). Pi runs it in the sandbox, prints its final message, and exits. Pi doesn’t ask for approval before it runs tools, so the agent runs shell commands and edits files without stopping.
--model. Run pi --list-models anthropic in the sandbox to see the IDs, then pick one, for example pi --model claude-haiku-4-5 -p "...".
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. With Anthropic, Pi needs only
api.anthropic.com to run, plus registry.npmjs.org if you install it after you restrict the network. If you deny all other traffic, also allow the sandbox’s DNS resolvers, 1.1.1.1/32 and 8.8.8.8/32, so these names resolve.Get JSON output
Use--mode json to get one JSON event per line. The first line is the session header, with the session ID in id. The last message_end event holds the final answer, as text blocks in message.content.
tool_execution_start, tool_execution_end) and streamed text (message_update). See Pi’s JSON event stream reference for every event type.
Continue a session
Pi saves each run as a session. Pass the session ID to--session to send a follow-up with the earlier context, or use -c to continue the most recent session in the current directory.