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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openai_agents_opsen-0.1.3.tar.gz.
File metadata
- Download URL: openai_agents_opsen-0.1.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71048892809e48d076530a7a0bd95abce8e6fc9a242986dc6fbeb5f07996d70e
|
|
| MD5 |
d4860076cc9080eb65db03659a5794ef
|
|
| BLAKE2b-256 |
916eeefd80845c2e0edbcf05a193fdf9313417fc9cc21aa7698c1fd47525f9a6
|
Provenance
The following attestation bundles were made for openai_agents_opsen-0.1.3.tar.gz:
Publisher:
release.yml on md322613/opsen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openai_agents_opsen-0.1.3.tar.gz -
Subject digest:
71048892809e48d076530a7a0bd95abce8e6fc9a242986dc6fbeb5f07996d70e - Sigstore transparency entry: 2753855213
- Sigstore integration time:
-
Permalink:
md322613/opsen@fb871fc1862bc1b4c7bee14a6cabcc5aa2096689 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/md322613
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fb871fc1862bc1b4c7bee14a6cabcc5aa2096689 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openai_agents_opsen-0.1.3-py3-none-any.whl.
File metadata
- Download URL: openai_agents_opsen-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2862ba182a3e2676df378e972e22619081144b99df8122a71590092ff3ed7de7
|
|
| MD5 |
ae36c0bb4d096767a4d4ed830cecf2f4
|
|
| BLAKE2b-256 |
b39971a5743741ff06b838183864de6dc072c8a66d6a459caa428da45c2a8f66
|
Provenance
The following attestation bundles were made for openai_agents_opsen-0.1.3-py3-none-any.whl:
Publisher:
release.yml on md322613/opsen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openai_agents_opsen-0.1.3-py3-none-any.whl -
Subject digest:
2862ba182a3e2676df378e972e22619081144b99df8122a71590092ff3ed7de7 - Sigstore transparency entry: 2753855234
- Sigstore integration time:
-
Permalink:
md322613/opsen@fb871fc1862bc1b4c7bee14a6cabcc5aa2096689 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/md322613
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fb871fc1862bc1b4c7bee14a6cabcc5aa2096689 -
Trigger Event:
push
-
Statement type: