langchain-opsen
Run LangChain deepagents on opsen — with machine, model and tool spend on one bill and a budget the runtime enforces mid-run.
pip install langchain-opsen
from deepagents import create_deep_agent
from langchain_anthropic import ChatAnthropic
from langchain_opsen import OpsenSandbox
agent = create_deep_agent(
model=ChatAnthropic(model="claude-sonnet-4-6"),
system_prompt="You are a Python coding assistant.",
backend=OpsenSandbox(task_id="nightly-report", budget_usd=2.00),
)
Set OPSEN_API_KEY, or pass api_key=. Get one here:
What this adds
Every sandbox backend 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, so:
agent_cost = backend.cost()
# {'total_usd': 0.41, 'compute_usd': 0.02, 'tokens_usd': 0.39,
# 'calls': 34, 'input_tokens': 84120, 'output_tokens': 9310,
# 'task_id': 'nightly-report'}
budget_usd is a ceiling the gateway enforces during the run. An
agent that would cross it is refused mid-flight rather than noticed
afterwards on an invoice.
Behaviour worth knowing
The session starts lazily. Constructing OpsenSandbox starts no
machine — the first command does. An agent built and never run costs
nothing.
File operations and the shell share one channel. Both go through the
same exec path, so the file tools and execute() always agree about the
working directory.
Ports depend on the runtime. host(port) 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. A provider that hands
back a URL which does not answer turns "preview my server" into a
debugging session.
Configuration
| Argument | Default | Meaning |
|---|---|---|
api_key |
$OPSEN_API_KEY |
From opsen.dev/keys |
task_id |
"deepagents" |
Groups this agent's spend. One id, one line on the spend page. |
budget_usd |
none | Hard ceiling, enforced mid-run |
labels |
{} |
Arbitrary tags — customer, environment, whatever you group by |
base_url |
https://opsen.dev |
For self-hosted deployments |
timeout |
300 |
Default seconds per command |
Licence
Apache-2.0
Metadata
Release files for langchain-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 | |
|---|---|---|---|---|
| langchain_opsen-0.1.6.tar.gz | 6.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_opsen-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / langchain_opsen-0.1.6.tar.gz
| Download URL | langchain_opsen-0.1.6.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57b67b9581eef6fe5821d134305e1a322e20947a32004328f98003e1c735da93
|
|
BLAKE2b-256 checksum How to use checksums |
9ebacb1dd0ed9b994c5e566c21e0eba12fc6de58f9493810193b38c69833486d
|
| 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 / langchain_opsen-0.1.6-py3-none-any.whl
| Download URL | langchain_opsen-0.1.6-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f217d42a0283d2a670f68195bc9172d97c42c002753bd4fe348b24883ebbfd81
|
|
BLAKE2b-256 checksum How to use checksums |
759016d6d6141fa8c24bc5ac910ead7b7e051c8e3566ce08fc1d81d6101efb2b
|
| 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 langchain-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 langchain_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.