BoxRouterSandboxClient is that client: each agent run gets its own BoxRouter sandbox, and BoxRouter picks the route. For OpenAI’s hosted Agents API, see Agents API.
Before You Begin: A BoxRouter API key, a connected provider key or Credits, and Python 3.11 or later.
Install
The package installs the BoxRouter Python SDK as a dependency.Open a Session
Set your BoxRouter API key as in the quickstart. This script prints a unique run label before creating a sandbox, so you can find it if creation is uncertain. It needs no model key. Save it assession.py:
async with block requests sandbox destruction. If the script dies first, the sandbox can run past the end of its lifetime_seconds lifetime (300 in this example; 900 when unset).
If you don’t know whether the sandbox was created, list sandboxes by the run label before retrying. The label helps you find and destroy a sandbox that may have started.
root is the directory the SDK treats as the workspace. Choose a directory the sandbox user can write to, such as /tmp/boxrouter-workspace. Files there last for the sandbox session.
Run an Agent in It
For a model-driven run, pass the same client and options inRunConfig. Set OPENAI_MODEL and the model provider’s key, such as OPENAI_API_KEY. Save this as agent.py:
lifetime_seconds lifetime (300 in this example). Use the printed run label to find it, then destroy it.
The Agents SDK sandbox guide covers building the SandboxAgent.
Limits
- Manifest mounts are refused before a sandbox is created, and PTY sessions are not supported.
- If the recorded sandbox is gone when the SDK resumes a session, the client creates a new one. It restores the workspace from the SDK’s snapshot; processes and files outside the workspace do not carry over.
- Errors carry the BoxRouter
code,request_idandoutcome. Onlyrate_limitedandoverloadedwith outcomenot_startedare marked retryable; for anything else, check the sandbox before you replay the call. - If creation fails with
no_eligible_route, no route met your request; Sandboxes shows how to read the refusal.
Next Steps
Use the OpenAI Agents API
OpenAI’s hosted Agents API instead.
Create a Sandbox
What a sandbox request can ask for.
Run Commands
Exit codes, timeouts, and output limits.