Run Pi in OpenShell
This tutorial runs Pi, a terminal coding agent, with the Anthropic API. You will build Pi into an OCI image, configure narrowly scoped model access, and run it inside OpenShell.
Build the Pi Image
Pi does not publish an official OCI image. Its
container guide installs the
maintained @earendil-works/pi-coding-agent npm package into a Node.js image.
Create Dockerfile.pi with the same approach:
Build the image with the container engine used by your local gateway:
For Podman, use podman build -t localhost/pi-agent:local -f Dockerfile.pi .
and substitute localhost/pi-agent:local in the commands below. For a remote
gateway, push the image to a registry the gateway can pull from. Pin
PI_VERSION to a reviewed release when you publish a reproducible image.
Configure Anthropic Access
Create pi-anthropic.yaml. The profile permits only the Pi executable from
this image to reach the Anthropic API. OpenShell supplies a credential
placeholder to Pi and replaces it only on requests to the declared endpoint.
Lint and import the profile into your current workspace, then store an Anthropic API key in a provider:
Create the Pi Sandbox
Create the sandbox, attach the provider, and run Pi interactively:
The command after -- is the sandbox’s main process. Pi and every command it
starts run inside the sandbox boundary. Try asking Pi:
To give Pi a local project, upload it before the main process starts:
The provider grants Pi access to api.anthropic.com. The built-in fallback
policy grants access to the working directory and standard runtime paths while
denying all other network egress. Add a reviewed custom policy when Pi needs
package registries, source hosts, tool servers, or other destinations.
Adapt the Pi Workflow
Pi supports multiple model providers. Create or adapt a provider profile for
the service you use, and make its binaries paths match the Pi installation in
your image. The OpenShell repository contains reviewable profile examples in
providers/.
Install any additional compilers, package managers, and agent tools in the image. Grant their filesystem and network requirements through sandbox policy instead of giving the workload broad access. Refer to Profiles for credential and endpoint configuration.
Verify and Troubleshoot
Inspect the sandbox, effective policy, provider attachments, and logs:
If pi is missing, confirm that the image was built with the selected local
container engine or pushed to a registry visible to the gateway. If a model
request is denied, confirm that the profile’s binaries paths match
command -v pi and npm root -g inside the image. Review any other denied
network or filesystem operation before updating the sandbox policy.
Next Steps
- To give Pi access to source control, package registries, or tool servers, add the corresponding provider profiles or a reviewed sandbox policy.
- To understand image, resource, upload, and lifecycle options, refer to Sandboxes.
- To configure another model service, refer to Profiles.