Prerequisites
Before you begin, you need the following:- macOS 또는 Linux 터미널, Python 3.12 이상,
uv - 샌드박스 액세스에 사용할 W&B API 키. 예시에서는 W&B 인증을 명시적으로 선택합니다.
- Pi에서 지원하는 모델 공급자의 자격 증명. 이 가이드에서는 W&B Serverless Inference를 사용하며, 추론 크레딧이 필요합니다.
- 공개 Git 저장소 URL. 비공개 저장소를 사용하려면 샌드박스 내에서 별도로 Git 인증을 설정해야 합니다.
Prepare your local environment
Create a local project and install the Sandbox software development kit (SDK):[WANDB-API-KEY]를 W&B API 키로 바꾸세요.
Create the sandbox
Save the following script ascreate_pi_sandbox.py. It creates a CPU sandbox, installs Pi 0.87.1, and clones the repository. The Node.js image supplies the runtime and Git. If setup fails, the script stops the sandbox before raising the error.
create_pi_sandbox.py
[REPOSITORY-URL] with your repository URL, then run:
0.87.1. The sandbox remains running after the script exits, until you stop it or its 4-hour lifetime expires. The lifetime includes startup time.
Attach your terminal
Save the following asattach_sandbox.py. It forwards your terminal input to a Bash shell in the sandbox and restores your local terminal settings when the shell exits.
attach_sandbox.py
[SANDBOX-ID] with your sandbox ID:
Choose a model provider
다음 옵션 중 하나를 선택하세요. 샌드박스 인증과 모델 인증은 둘 다 W&B 키를 사용하더라도 서로 별개입니다. Pi는 자신의 프로세스에 제공된 자격 증명에 액세스할 수 있으며, 워크스페이스 콘텐츠를 선택한 모델 공급자에게 보낼 수 있습니다.Use Serverless Inference
We recommend W&B Serverless Inference for this walkthrough. The example useszai-org/GLM-5.2. Choose another model from the model catalog if it better fits your task.
샌드박스 셸에서 입력 내용이 표시되지 않는 프롬프트에 W&B 추론 키를 입력하세요. 계정에 추론 크레딧이 있으면 샌드박스 액세스에 사용한 W&B 키를 그대로 사용할 수 있습니다.
~/.pi/agent/models.json file. The quoted heredoc preserves the environment-variable reference so the file doesn’t contain the key:
/workspace/project and zai-org/GLM-5.2 in the status area. Submit a task in Run Pi and check its work to verify model access.
The configuration limits each response to 8,192 tokens. If you change models, update the model ID and capabilities to match the provider. For more configuration options, see Pi model configuration.
Use another provider
To use Anthropic or OpenAI directly, choose the corresponding API key and start Pi in the same sandbox shell:- Anthropic
- OpenAI
/model inside Pi to choose a model available to your provider. The Pi provider documentation linked in the prerequisites covers other providers and account sign-in options.
Run Pi and check its work
If Pi displays a project trust prompt, follow it. To check that Pi can create and read a file in the cloned repository, submit this task in Pi:/quit to return to the sandbox shell. Pi prints a To resume this session: line with a pi --session command. Keep that command to reopen this conversation.
Verify the file independently:
Hello from CoreWeave.
For an unattended task with the W&B setup, run Pi in print mode from the same shell:
Reconnect to a conversation
To reconnect while the sandbox is running, run theattach_sandbox.py script again. Re-enter any API keys supplied through the previous shell and return to the /workspace/project directory before starting Pi. To reopen your interactive conversation, replace [SESSION-ID] with the ID from the To resume this session: line Pi printed when you exited:
pi --continue resumes the most recent session for the project. If you ran the print-mode example after your interactive conversation, it resumes the print-mode session. Use --session to return to a specific conversation.
Retrieve the result and stop
Enterexit to leave the sandbox shell. In your local terminal, save the following as collect_pi_result.py:
collect_pi_result.py
[SANDBOX-ID] with your sandbox ID and run the script:
stop_pi_sandbox.py:
stop_pi_sandbox.py
Troubleshoot
Use these checks to resolve common issues:- If sandbox creation fails, check your sandbox credential and the sandbox authentication requirements linked in the prerequisites.
- If Pi can’t authenticate, check that the model credential is exported in the shell that starts Pi. With W&B, also check inference credits and the model ID.
- If Pi can’t reach its provider, check outbound access to the provider endpoint. Installation and cloning also require access to npm and your Git host.
- If your connection drops, attach again while the sandbox runs. If you need a process to survive terminal disconnections, use a terminal multiplexer such as
tmux.
Next steps
For more information, see the following resources:- Interactive shells covers terminal access through the SDK.
- File operations covers uploading and retrieving workspace files.
- Pi documentation covers sessions, model selection, and extensions.