Orblealpha

OpenAI Agents API

Use Orble boxes as self-hosted environments for the OpenAI Agents API. codex exec-server runs in the box and connects to the session over an outbound WebSocket. Guest memory and process state are preserved when the box is suspended between turns, so the same executor reconnects on resume.

Create an Orble API key in Settings, an OpenAI API key, and an environment key on the Agents tab of the OpenAI platform dashboard. Pass only the environment key into the box, as CODEX_API_KEY.

$ pip install orble-sdk openai$ export ORBLE_API_KEY=orble_...$ export OPENAI_API_KEY=sk-...$ export OPENAI_EXECUTOR_API_KEY=sk-...$ python main.py
main.py
import os

import orble
from openai import OpenAI

client = OpenAI()
session = client.beta.agents.sessions.create(
    agent={"model": "gpt-5.6-sol"},
    environment={"type": "self_hosted", "workspace_directory": "/workspace"},
)

box = orble.create()
box.keep_awake()
box.exec("sudo mkdir -p /workspace && sudo chown agent /workspace"
         " && npm install -g @openai/codex@alpha", timeout=300)
box.exec(
    "setsid nohup codex exec-server"
    f" --remote {session.environment.remote_url}"
    f" --environment-id {session.environment.id}"
    " > /tmp/codex-executor.log 2>&1 < /dev/null &",
    cwd="/workspace",
    env={"CODEX_API_KEY": os.environ["OPENAI_EXECUTOR_API_KEY"]},
)

with client.beta.agents.sessions.stream(
    session.id, input="Write hello to hello.txt."
) as events:
    for event in events:
        if event.type == "agent.session.turn.output_text.delta":
            print(event.delta, end="")

print(box.read("/workspace/hello.txt"))
box.suspend()  # files, memory and the executor are kept until box.resume()
Executor

Create one box per session. Install the executor with npm install -g @openai/codex@alpha and run codex exec-server in the background with the session's remote_url and environment ID

Keep awake

Disable automatic suspension while a turn runs, so the box stays up while the model works between commands

Between turns

Suspend the box, or restore automatic suspension, to stop CPU charges. Files, memory and the running executor are preserved. Resume the box before sending the next input

Webhooks

Create or resume the box on agent.session.action_required with an environment_connection action, disable automatic suspension on agent.session.in_progress, restore it on agent.session.idle, and delete the box on agent.session.failed

Cleanup

Delete the box and the session separately. Deleting a session leaves its box running

Network

The executor needs outbound HTTPS to api.openai.com and codex-cloud-environments.chatgpt.com. With Orble Pro egress rules, allow both hosts