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 here:
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. getHost-style 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.
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 id — 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
Metadata
Release files for openai-agents-opsen 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| openai_agents_opsen-0.1.6.tar.gz | 5.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openai_agents_opsen-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / openai_agents_opsen-0.1.6.tar.gz
| Download URL | openai_agents_opsen-0.1.6.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6eca8aebab79d671af0f829bdd77eb2d41d832ce095e1dd207e21eca32b3486b
|
|
BLAKE2b-256 checksum How to use checksums |
5f6bba8ce3b7f565f4971d4ef6f1392c54a2bdef1e38547e547522483c463f2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logRelease files / openai_agents_opsen-0.1.6-py3-none-any.whl
| Download URL | openai_agents_opsen-0.1.6-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad845edeb0ad5be5e0db148b3d677edace258717ac360db1ca2ab9ea19099a77
|
|
BLAKE2b-256 checksum How to use checksums |
c52188cb0eada32ab1c8b30301dee9587209039c4f0dbe3349f7308553191a9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logSecurity for openai-agents-opsen 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for openai_agents_opsen-0.1.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.