Create an openai_hosted environment using POST /v1/agents/environments with packages, files, and setup_commands. Poll the environment until it reaches ready, or use a webhook. When the task arrives, pass the resulting environment_id while creating the Agent Session. Official guidance also permits attaching while setup continues; agent access waits until setup completes. Pre-warm close to expected task arrival, as unattached environments expire after about five minutes. Official examples require at least Python SDK 3.27.0 or Node.js SDK 7.31.0, with language-specific minimum versions for others. Pre-warming is free only before attachment; standard container billing applies afterward. Check permissions, SDK versions, reuse behavior, and expiry handling. This is a documentation-based walkthrough, not an independently executed test.
OpenAI API / Agents / Tutorial & Workflow
Pre-warming OpenAI Agents API Sandboxes to Reduce Startup Latency
OpenAI documents a workflow to prepare an Agents API sandbox, install dependencies, and load files before creating an Agent Session, then attach it by environment ID. Developer VeitB summarized the process on October 12: pre-warming before attachment is free, unattached environments expire after about five minutes, and standard container pricing starts after attachment. Useful for latency-sensitive applications; examples were not independently tested.
