1. Get your keys
- A Box API key from the Upstash Console.
- An OpenAI API key from API keys.
- An environment key from Agents → Environments → Keys, in the same project. It’s the only OpenAI key that goes into the box.
.env
2. Run a session
session.ts
3. Continue later
Pass the printed IDs to continue the same session in the same box:resume.ts
Customize the box
Pass anyBox.create option when you create the box:
CODEX_API_KEY is readable inside the box, which is why it must be the environment key. Open a server the agent started with box.getPublicURL(3000). To start every box with your own tools or repo, create it with Box.fromSnapshot instead.
Troubleshooting
- Script waits and prints nothing: the executor didn’t connect. Check
/workspace/home/executor.login the box. missing required scope api.agents.environments.connect:OPENAI_EXECUTOR_KEYmust be an environment key, not a regular API key.