opsen

Getting started

Three steps, and your agent needs no opsen code.

1. Sign up and add credit

You are billed for what you use at provider cost plus 5%. Nothing expires and unused credit is refundable.

2. Point us at your code

POST /v1/sessions
{ "task_id": "invoice-extract", "budget_usd": 2.00 }

3. Or use a client

pip install opsen
from opsen import Opsen

opsen = Opsen()                      # reads OPSEN_API_KEY

with opsen.session(task_id="job_8812", budget_usd=2.0) as s:
    s.write("agent.py", code)
    s.exec("python3 agent.py")
    print(s.cost())

Your agent needs no opsen code

The sandbox starts with ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, OPENAI_BASE_URL and OPENAI_API_KEY already set. Any SDK inside it routes through us with no configuration, and every call is attributed to the session.

The injected key is a session token, not a provider key. It is scoped to one session, capped by that session's budget, dead when the session ends, and useless anywhere else. That is deliberate: a long-lived provider key inside a machine running generated code is the thing this design exists to avoid.

import anthropic

client = anthropic.Anthropic()       # no api_key, no base_url
msg = client.messages.create(
    model="auto",                    # or name one
    max_tokens=400,
    messages=[{"role": "user", "content": "hello"}],
)

From the command line

opsen run agent.py
opsen tasks
opsen cost invoice-extract

The full API

Every endpoint, with its schema, at /api-reference.