Skip to main content

openai-agents-opsen

Run OpenAI Agents SDK sandboxes on opsen — with machine, model and tool spend on one bill and a budget the runtime enforces mid-run.

pip install openai-agents-opsen
from agents import Runner, RunConfig
from agents.sandbox import SandboxAgent
from openai_agents_opsen import OpsenSandboxClient

agent = SandboxAgent(name="Worker", instructions="...")

result = await Runner.run(
    agent,
    "read the repo and summarise it",
    run_config=RunConfig(
        sandbox={"client": OpsenSandboxClient(
            task_id="code-review",
            budget_usd=2.00,
        )}
    ),
)

Set OPSEN_API_KEY, or pass api_key=. Get one at opsen.dev/keys.

What this adds

The SDK ships with Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop and Vercel. Every one of them bills you for the machine and leaves the model bill with a different vendor, on a different invoice, with no shared identifier. Two bills, reconciled by hand, and no answer to "what did that agent cost".

opsen sits in both paths:

session.cost()
# {'total_usd': 0.41, 'compute_usd': 0.02, 'tokens_usd': 0.39,
#  'calls': 34, 'input_tokens': 84120, 'output_tokens': 9310,
#  'task_id': 'code-review'}

budget_usd is a ceiling enforced during the run. An agent that would cross it is refused mid-flight rather than noticed afterwards.

Behaviour worth knowing

Exit codes pass through. The SDK decides whether a step failed from the exit code, so it is returned unchanged rather than flattened.

Commands are quoted, not joined. The SDK hands over argv; " ".join() would turn ("sh", "-c", "exit 3") into a different command that quietly succeeds.

Ports depend on the runtime. Port exposure works on E2B, works on Modal when the port was declared at sandbox creation, and raises on the local runtime with a message naming the limitation — rather than handing back a URL that never answers.

Resume carries opsen's own session id. SandboxSessionState.session_id is typed as a UUID and opsen's ids are not, so the state subclasses to keep the real one — the same approach the SDK's own UnixLocalSandboxSessionState takes.

Configuration

Argument Default Meaning
api_key $OPSEN_API_KEY From opsen.dev/keys
task_id "agents-sdk" Groups this agent's spend
budget_usd none Hard ceiling, enforced mid-run
labels {} Arbitrary tags to group spend by
base_url https://opsen.dev For self-hosted deployments

Why a separate package

The SDK maintainers do not take third-party provider implementations into the repo — see PR #3469, where a fully tested NVIDIA OpenShell provider was closed with a preference for "a separate package maintained by the provider team". This is that package.

Licence

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openai_agents_opsen-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openai_agents_opsen-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file openai_agents_opsen-0.1.1.tar.gz.

File metadata

  • Download URL: openai_agents_opsen-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for openai_agents_opsen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e80c198ff7b7de282d57e8ffcebd5ac3d7b283ba011d7a63013fadc5e19c8bfd
MD5 b1879ffc9a42b99803ebe6c9705abb09
BLAKE2b-256 5c5557495fa650ce7e7d684717a6b10cb0b3416b1d9a34fb8bb712591d70aeb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for openai_agents_opsen-0.1.1.tar.gz:

Publisher: release.yml on md322613/opsen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openai_agents_opsen-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openai_agents_opsen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2e8239b116707bbaa53776ee795c0b7a0282f4c877341ee48811526899033b7
MD5 ad8e742e52514b42bdd43f134fa5e83a
BLAKE2b-256 ae2fa464bd483581c2461dd89973b6b1258aa8abe32c5b5d859fadefc9cdea48

See more details on using hashes here.

Provenance

The following attestation bundles were made for openai_agents_opsen-0.1.1-py3-none-any.whl:

Publisher: release.yml on md322613/opsen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page