Prerequisites
- Python 3.11 through 3.14 and Git
- An OpenAI project with Agents API access and two keys in the same organization, project, and owner:
OPENAI_API_KEY, the project key. It stays with your application.OPENAI_EXECUTOR_API_KEY, a separate restricted executor key created in the same project by the same owner. It is required in every agent mode and is the only OpenAI key passed to worker Sandboxes.
- A Blaxel workspace, using an installed Blaxel CLI with
bl login, or provided asBL_WORKSPACEandBL_API_KEY(API keys) - Public PyPI access to install the cookbook dependencies with
./run.sh
us-was-1 is optional for the first run and required for the optional fresh-session handoff.
The Agents API is a public beta. This walkthrough uses the public
openai package and client.beta.agents. It is separate from the OpenAI Agents SDK tutorial.OPENAI_API_KEY on the API keys page with Agents read/write and Responses write permissions. Create a separate OPENAI_EXECUTOR_API_KEY on the Agents environment-key page, in the same organization, project, and user or service account as the session. Set all other permissions to None. The environment key permits connecting the executor only; a generic restricted API key with List models access does not establish that permission.
Both keys are required. Missing or identical keys fail before a worker is provisioned. The application key stays outside workers; only the environment key is passed as CODEX_API_KEY to codex exec-server. Follow the OpenAI self-hosted setup for the current dashboard flow.
These examples create hosted resources and invoke a model. Your local script creates a session and a computer, runs the file task, verifies the result, and deletes the temporary resources.
1. Configure and run the cookbook
The default
auto mode uses Agent Drive when available. Set BL_AGENT_DRIVE_MODE=off before the run for completely disposable storage.sample_report.txt and writes summary.md.
OpenAI manages the agent session. Blaxel supplies the computer that runs its commands. The executor connects outbound to OpenAI; the first run requires no webhook deployment or public worker port.
2. Open your summary
Open the printedoutputs/<run-id>/summary.md path in your editor. Check how the agent summarizes the failures, assigns follow-up work, and handles the missing-data caveat.
The script verifies file use before saving the local copy. It also confirms that its new turn completed and both temporary resources were deleted. These are selected output lines; the run also prints the local output and retained Drive paths:
Without Agent Drive access, the baseline uses temporary storage and still saves your local summary before deleting the computer.
3. Continue in a fresh session
Agent Drive becomes most useful when another agent continues from an explicit file instead of copied conversation history.summary.md, then its session and Sandbox are deleted. A fresh session and Sandbox mount the same Drive, read that file, and write review.md:
summary.md and review.md remain in the same Agent Drive run directory. The second agent must read the original verification marker before its review passes.
Agent Drive shares inspectable files. It does not copy model memory, conversation history, or session state.
outputs/<run-id>/summary.md and outputs/<run-id>/review.md from this run. Both local copies share the original run’s directory.
The handoff requires Agent Drive in us-was-1. It refuses BL_AGENT_DRIVE_MODE=off and reports an access or region error when persistence is unavailable.
4. Adapt the task
Replacesample_report.txt with your own document. Change the first agent’s prompt and output check in main.py, and the follow-up task in handoff.py. Keep a check tied to your input so a completed turn alone cannot pass as useful work.
The cookbook keeps session creation, computer setup, the task, verification, and cleanup visible. The baseline uses one session and computer. Handoff adds a second pair only after the first is gone.
Prompt your coding agent
After configuring the credentials above, you can give a coding agent this task:5. Review cleanup
The scripts delete their temporary sessions and computers. Local files inoutputs/ and files on Agent Drive are retained intentionally. Inspect or export the Drive’s files before deleting it.
For an interrupted run, use the exact printed receipt from the same Blaxel workspace and endpoint:
Troubleshooting
Resources
OpenAI Agents API integration reference
Review credentials, storage policy, execution modes, and lifecycle behavior.
Cookbook and optional examples
Adapt the baseline, or explore the separate team and webhook guides.
Agent Drive
Configure persistent files and access permissions.