Skip to main content
Pi is a minimal, open-source terminal coding agent from pi.dev. Run it in a Superserve sandbox so its shell commands and file edits stay isolated from your machine.

Via the console

  1. 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.
  2. Go to console.superserve.ai and click Create sandbox.
  3. Pick the superserve/node-22 template.
  4. Under Advanced Options → Secrets, bind that secret to ANTHROPIC_API_KEY.
  5. Create the sandbox, open its Terminal, and run:

Via the SDK

Pi reads 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.
Pi picks a default Anthropic model unless you pass --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.
Other events report tool calls (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.

Work on a repository

Clone a repository into the sandbox, stream Pi’s output while it works, then read the diff.

Persist sessions