An open-source, faster Devin alternative
TypeScript
token-billing step 7: docs — Managed option + scrub OpenRouter; codex validated
Igor Zalutski32d966679a66
diff --git a/.agents/work/token-billing.md b/.agents/work/token-billing.mdindex fdcd9139..1aede18f 100644--- a/.agents/work/token-billing.md+++ b/.agents/work/token-billing.md@@ -454,9 +454,9 @@ accepts a reserved value `"managed"`:Managed changes *who pays*, not *which models* — both Managed and BYO show theruntime's models. (Managed's broader reach is **across agents/runtimes**, not withinone agent.)-- **§9.7:** claude *likely* feasible, **codex unvalidated** (the `wire_api:"responses"`- path — §5.2/§9.7); a runtime is offered under Managed only once its OR path is- validated end-to-end.+- **§9.7:** both `claude` and `codex` **validated end-to-end live on prod**+ (2026-06-29) — incl. codex's `wire_api:"responses"` + `requires_openai_auth=false`+ path through OR. Both runtimes are offered under Managed.**Behavior.**- Out of credits (Managed) → same halt as compute (one pool); "top up to resume."@@ -1005,10 +1005,11 @@ malformed values that already would have failed now fail earlier and clearer.ref validation + key/credential exclusion; `422 managed_unavailable`. 2B:`endpoint_profile` on `TurnConfig` + seal keyed on (runtime, source) +`toOpenRouterSlug` (Anthropic dash→dot); both runtime servers route Managed- through OR. tsc clean (3 packages). **NOT yet smoke-tested with a live Managed- turn** (needs dev stack + funded float; codex `requires_openai_auth=false`- validated only at raw-HTTP, not through the CLI). Apply migration 015 + set- `OC_MANAGED_CRED_HMAC_SECRET` to enable.+ through OR. **SHIPPED + validated live on prod 2026-06-29: both claude AND codex+ Managed turns run end-to-end through OpenRouter** (org `2f9094d9`); codex's+ `requires_openai_auth=false` CLI path — the last §9.7 unknown — **confirmed+ working live**. Runtime brains shipped as org-scoped snapshots (claude v0.0.11,+ codex v0.0.5).3. **Edge — metering + enforcement:** `model_meter` cron — persist-before-trackimmutable-interval debit (§5.4/§7), markup-correct **aggregate** cap across keys(§5.4/§7), `projectOrg` halt on ≤0 (§5.4); reconcile cron (§5.7).diff --git a/docs/agent-sessions/agents.mdx b/docs/agent-sessions/agents.mdxindex 228cebcc..b7e5cfc3 100644--- a/docs/agent-sessions/agents.mdx+++ b/docs/agent-sessions/agents.mdx@@ -40,7 +40,7 @@ Content-Type: application/json</CodeGroup>-Pass your model `key` inline and it's stored as a [credential](/agent-sessions/credentials) and attached to the agent — sessions run the model on it. The provider is taken from `model` (Anthropic for `anthropic/…`, OpenAI for `openai/…`), so the key has to be for that provider. Already have a credential? Reference it with `credential: "cred_…"` instead, or omit both to use your org default for that provider. Optionally set default [`limits`](/agent-sessions/sessions#limits) (`tokens`/`turn_seconds`/`turns`) too; sessions inherit them.+Pass your model `key` inline and it's stored as a [credential](/agent-sessions/credentials) and attached to the agent — sessions run the model on it. The provider is taken from `model` (Anthropic for `anthropic/…`, OpenAI for `openai/…`), so the key has to be for that provider. Already have a credential? Reference it with `credential: "cred_…"` instead. Or skip keys entirely with `credential: "managed"` to run the model **via OpenComputer, billed to your credits** (the default for new orgs). Omit both `key` and `credential` to use your org default. Optionally set default [`limits`](/agent-sessions/sessions#limits) (`tokens`/`turn_seconds`/`turns`) too; sessions inherit them.<Tip>Keep the org key and model key on your backend. Only return session-scoped client tokens to browsers.</Tip>@@ -50,4 +50,4 @@ When a session is created it **freezes** the agent's `prompt`, `model`, `runtime## Model-`model` is a `provider/model` id, and its provider must match the [runtime](/agent-sessions/runtimes): `claude` runs `anthropic/…` (e.g. `anthropic/claude-opus-4-8`), `codex` runs `openai/…` (e.g. `openai/gpt-5-codex`). The model runs on [your own key](/agent-sessions/credentials) for that provider (required). The `runtime` / `model` / credential pairing is validated when you **create** the agent. `runtime` is fixed at creation — to switch engines, create a new agent; you can still update `model` later, but keep it within the runtime's provider.+`model` is a `provider/model` id, and its provider must match the [runtime](/agent-sessions/runtimes): `claude` runs `anthropic/…` (e.g. `anthropic/claude-opus-4-8`), `codex` runs `openai/…` (e.g. `openai/gpt-5-codex`). The model runs either **Managed** (via OpenComputer, billed to your credits — no key) or on [your own key](/agent-sessions/credentials) for that provider, so a key isn't required. The `runtime` / `model` / credential pairing is validated when you **create** the agent. `runtime` is fixed at creation — to switch engines, create a new agent; you can still update `model` later, but keep it within the runtime's provider.diff --git a/docs/agent-sessions/api-reference.mdx b/docs/agent-sessions/api-reference.mdxindex a20813b7..a6b6099f 100644--- a/docs/agent-sessions/api-reference.mdx+++ b/docs/agent-sessions/api-reference.mdx@@ -55,7 +55,7 @@ const session = await oc.sessions.get("ses_..."); // server, org key</Tabs>-`agent` is **required** (create a saved [agent](#agents) first); a resolvable model [credential](#credentials) is also required (`422 no_credential` otherwise). `key` gives get-or-create (one session per key); a request-level `Idempotency-Key` header makes a keyless create retry-safe. `metadata` is opaque **application routing state** — a JSON object (≤ 16 KB) stored on the session, returned by get/list, and delivered **verbatim in webhooks** so a callback handler can route to the right external record without a lookup; it is **never** shown to the model, **not** indexed/queryable, and distinct from `key` (get-or-create) and `Idempotency-Key` (dedupe). `input` is the task — a string or a full [envelope](/agent-sessions/messaging#message-input). For the managed runtimes (`claude`, `codex`), put all task-critical context in the task text. There's no fixed byte cap on `input`, but it counts against the model's context window — **truncate large inputs** (e.g. a PR diff) and have the agent pull the rest through its [sandbox tools](/agent-sessions/runtime-tools) (clone the repo, read files) rather than inlining it. `limits` `{ tokens, turn_seconds, turns }` are **non-monetary** — token budget, per-turn wall-clock, auto-run count; hitting one ends the turn with a matching `last_turn.yield_reason`. Destinations on an idempotent create-replay are ignored — manage them via the [destinations API](#destinations). `sources` checks out one or more repositories for the agent **before the first turn**; the checkout credential never enters the agent's sandbox (see [Repos & GitHub](#github-apps--repos)). Each entry references a registered [repo](#github-apps--repos) — `{ repo, ref, sha, name? }` — or is inline — `{ url, ref, sha, name?, auth }`. `ref` (the fetch ref, e.g. `refs/pull/N/head`) and `sha` are both **required**: the ref is fetched and the exact `sha` is pinned and verified. The create response echoes sanitized `sources`; poll `GET /sessions/:id/sources` for live status.+`agent` is **required** (create a saved [agent](#agents) first); the model must resolve to a source — **Managed** (billed to your credits, the default) or a usable [credential](#credentials) — else `422 no_credential` (or `422 managed_unavailable` if Managed is selected but not active for your org). `key` gives get-or-create (one session per key); a request-level `Idempotency-Key` header makes a keyless create retry-safe. `metadata` is opaque **application routing state** — a JSON object (≤ 16 KB) stored on the session, returned by get/list, and delivered **verbatim in webhooks** so a callback handler can route to the right external record without a lookup; it is **never** shown to the model, **not** indexed/queryable, and distinct from `key` (get-or-create) and `Idempotency-Key` (dedupe). `input` is the task — a string or a full [envelope](/agent-sessions/messaging#message-input). For the managed runtimes (`claude`, `codex`), put all task-critical context in the task text. There's no fixed byte cap on `input`, but it counts against the model's context window — **truncate large inputs** (e.g. a PR diff) and have the agent pull the rest through its [sandbox tools](/agent-sessions/runtime-tools) (clone the repo, read files) rather than inlining it. `limits` `{ tokens, turn_seconds, turns }` are **non-monetary** — token budget, per-turn wall-clock, auto-run count; hitting one ends the turn with a matching `last_turn.yield_reason`. Destinations on an idempotent create-replay are ignored — manage them via the [destinations API](#destinations). `sources` checks out one or more repositories for the agent **before the first turn**; the checkout credential never enters the agent's sandbox (see [Repos & GitHub](#github-apps--repos)). Each entry references a registered [repo](#github-apps--repos) — `{ repo, ref, sha, name? }` — or is inline — `{ url, ref, sha, name?, auth }`. `ref` (the fetch ref, e.g. `refs/pull/N/head`) and `sha` are both **required**: the ref is fetched and the exact `sha` is pinned and verified. The create response echoes sanitized `sources`; poll `GET /sessions/:id/sources` for live status.Client tokens accept `scopes?` (subset of `read`, `steer`) and `ttl?` seconds, clamped to 60–86400 (SDK: `ttlSeconds`).@@ -249,11 +249,11 @@ Delivery = {</Tabs>-Create body: `name`, `prompt`, `model`, `runtime?` (`claude` | `codex`), `key?`, `credential?`, `limits?`. Patch accepts `prompt?`, `model?`, `key?`, `credential?`, and `limits?` — **not `runtime`, which is fixed at creation**. The `runtime` / `model` / credential provider must agree (`claude`↔`anthropic/…`, `codex`↔`openai/…`); this is validated at create, and a patched `model`/`credential` must stay within the runtime's provider.+Create body: `name`, `prompt`, `model`, `runtime?` (`claude` | `codex`), `key?`, `credential?`, `limits?`. Patch accepts `prompt?`, `model?`, `key?`, `credential?`, and `limits?` — **not `runtime`, which is fixed at creation**. The `runtime` / `model` provider must agree (`claude`↔`anthropic/…`, `codex`↔`openai/…`), validated at create. `credential` is a closed value: a `cred_…` id (BYO, must match the runtime's provider) **or** the literal `"managed"` — run the model **via OpenComputer, billed to your credits**, which bypasses the credential provider match (the `model` still must match the runtime). `key` and `credential` are mutually exclusive.`POST /agents` is **idempotent by `name`** — the outcome is in the **status code**, not a body field: a fresh create returns **201**; a repeat with matching non-secret config (`prompt`/`model`/`runtime`/`limits`) returns the existing agent with **200**; differing config returns **409**. Safe to call on every app startup or deploy. (`key` is ignored on a 200 hit — it never silently rotates.)-Pass `key` **or** `credential` (or neither → org default). The agent's `limits` are the defaults for its sessions; a session's own `limits` override. Each agent has a monotonic `revision` (bumped on PATCH) that sessions pin in `agent_snapshot.revision`, so you can tell which version produced a run.+Pass `key` **or** `credential` (`"managed"` or a `cred_…` id), or neither → org default (Managed when your org has no default key). The agent's `limits` are the defaults for its sessions; a session's own `limits` override. Each agent has a monotonic `revision` (bumped on PATCH) that sessions pin in `agent_snapshot.revision`, so you can tell which version produced a run.## GitHub Apps & Repos@@ -334,7 +334,7 @@ Responses **never** contain a token or secret. Registering a repo is **optional*</Tabs>-Credential body: `provider`, `key`, `name?`, `is_default?`. Keys are write-only. A credential is **required**; sessions run on your provider key. See the [Credentials](/agent-sessions/credentials) guide for resolution, rotation, and the dashboard.+Credential body: `provider` (`anthropic` | `openai`), `key`, `name?`, `is_default?`. Keys are write-only. A BYO credential is optional — agents can run **Managed** (`credential: "managed"`, billed to your credits, no key), the default for new orgs. See the [Credentials](/agent-sessions/credentials) guide for Managed vs BYO, resolution, rotation, and the dashboard.```Credential = { id, provider, name?, last4, is_default, created_at }diff --git a/docs/agent-sessions/authentication.mdx b/docs/agent-sessions/authentication.mdxindex 87ca7dbf..8d12fb0c 100644--- a/docs/agent-sessions/authentication.mdx+++ b/docs/agent-sessions/authentication.mdx@@ -77,6 +77,6 @@ For the SSE stream the browser passes the client token as `?token=` (native `Eve## Model credentials-Sessions run the model on **your own provider key** — Anthropic for the `claude` [runtime](/agent-sessions/runtimes), OpenAI for `codex`. The key is stored at rest in a dedicated secrets vault ([Infisical](https://infisical.com)), write-only, and **never returned** by the API. The real key never enters a sandbox: the runtime gets an opaque placeholder, and a [secret-store egress proxy](/sandboxes/secrets) swaps in the real value in flight, only on the outbound HTTPS call to the provider. A credential is **required**; a session with no resolvable key fails to start (`422 no_credential`).+Sessions run the model either **Managed** — via OpenComputer, billed to your **credits**, with no key (the default for new orgs) — or on **your own provider key** (Anthropic for the `claude` [runtime](/agent-sessions/runtimes), OpenAI for `codex`). A bring-your-own key is stored at rest in a dedicated secrets vault ([Infisical](https://infisical.com)), write-only, and **never returned** by the API. The real key never enters a sandbox: the runtime gets an opaque placeholder, and a [secret-store egress proxy](/sandboxes/secrets) swaps in the real value in flight, only on the outbound HTTPS call to the provider. A key isn't required — Managed needs none; a session fails to start (`422 no_credential`) only when it resolves to neither Managed nor a usable key.-The quickest way to add one is inline when you [create an agent](/agent-sessions/agents) (`"key": "…"`). To reuse a key across agents, set an org default, or rotate/remove keys, see the dedicated **[Credentials](/agent-sessions/credentials)** page.+For Managed, set an agent's `credential` to `"managed"` (or rely on the org default) — nothing to add. For BYO, the quickest way to add a key is inline when you [create an agent](/agent-sessions/agents) (`"key": "…"`). To reuse a key across agents, set an org default, or rotate/remove keys, see the dedicated **[Credentials](/agent-sessions/credentials)** page.diff --git a/docs/agent-sessions/credentials.mdx b/docs/agent-sessions/credentials.mdxindex 8ad575e0..d9f6627a 100644--- a/docs/agent-sessions/credentials.mdx+++ b/docs/agent-sessions/credentials.mdx@@ -1,10 +1,26 @@---mode: "wide"title: "Credentials"-description: "Bring-your-own model provider keys, held as hard secrets"+description: "Run models Managed (billed to your credits) or on your own provider keys"----Sessions run the model on **your own provider key** — Anthropic for the `claude` [runtime](/agent-sessions/runtimes), OpenAI for `codex`. A **credential** is that key, stored once and reused across [agents](/agent-sessions/agents). It's treated as a hard secret end to end: **encrypted at rest, never returned by the API, and never present inside a sandbox.** A credential is required — a session with no resolvable key fails to start (`422 no_credential`).+A session runs a model one of two ways:++- **Managed** — run it **through OpenComputer**, billed to your **credits**, with **no key to manage**. The default for new orgs, and selectable per agent. Nothing to store, rotate, or protect.+- **Bring your own key (BYO)** — your own provider key (Anthropic for the `claude` [runtime](/agent-sessions/runtimes), OpenAI for `codex`), stored once as a **credential** and reused across [agents](/agent-sessions/agents). It's treated as a hard secret end to end: **encrypted at rest, never returned by the API, and never present inside a sandbox.**++You don't strictly need a credential: an agent set to Managed needs no key. A session only fails to start (`422 no_credential`) when it resolves to **neither** Managed **nor** a usable key. The rest of this page is about BYO credentials; for Managed, just select it per agent (below).++## Managed vs BYO++| | **Managed** | **BYO credential** |+|---|---|---|+| Key | none — run via OpenComputer | your Anthropic / OpenAI key |+| Billing | your OpenComputer **credits** | your provider invoice |+| Setup | select it per agent (`credential: "managed"`) | add a credential (below) |+| Models | same `provider/model` ids, per [runtime](/agent-sessions/runtimes) | same |++Pick per agent: `credential: "managed"` runs Managed; a `cred_…` id (or an inline `key`) runs BYO; omit it to inherit the org default. New orgs default to Managed, so you can start with **no key at all** and switch to BYO whenever you want. The rest of this page covers BYO.## How your keys are protected@@ -19,6 +35,8 @@ Rotating a key's value reaches **running** sessions too, so a compromised key re## Add a credential+<Tip>Skip this entirely with **Managed** — set an agent's `credential` to `"managed"` (or rely on the org default) to run via OpenComputer billed to your credits, no key required. See [Managed vs BYO](#managed-vs-byo) below.</Tip>+Set `provider` to `anthropic` or `openai`. `name` is an optional label; `is_default` makes it your org default for that provider (see [resolution](#resolution)). The response is the credential's **metadata only** — the key is never echoed back.<CodeGroup>@@ -47,6 +65,8 @@ Attach it to an agent by id, so the agent runs on it:```ts TypeScript SDKawait oc.agents.create({ name: "reviewer", runtime: "claude", model: "anthropic/claude-opus-4-8", prompt: "…", credential: cred.id });+// …or run Managed (billed to credits, no key):+await oc.agents.create({ name: "reviewer", runtime: "claude", model: "anthropic/claude-opus-4-8", prompt: "…", credential: "managed" });```<Tip>Prefer not to touch the API? Add and manage credentials from the [dashboard](https://app.opencomputer.dev) under **Agents → Credentials** — and pick one (or add a new one inline) right in the create-agent dialog.</Tip>@@ -71,16 +91,18 @@ DELETE https://api.opencomputer.dev/v3/credentials/:idThe credential object: `{ id, provider, name?, last4, is_default, created_at }`. `last4` is the last four characters, for display — the key itself is never returned.-<Warning>Deleting a credential breaks agents pinned to it and sessions that fall back to it (they'll `422 no_credential` until you point them at another). Make sure another credential — or a new default — is in place first.</Warning>+<Warning>Deleting a credential breaks agents pinned to it and sessions that fall back to it, until you point them at another credential, at **Managed** (`credential: "managed"`), or set a new default. If your org has no other default, they fall back to Managed automatically.</Warning>## Resolution-When a session is created, the credential is resolved (and **pinned** for the session's life) in this order:+When a session is created, its model source is resolved (and **pinned** for the session's life) in this order:-1. The **agent's** credential, if it has one and it matches the runtime's provider.-2. Your **org default** for that provider.+1. The agent's **`credential: "managed"`** → run Managed, billed to your credits.+2. The **agent's** BYO credential, if it has one and it matches the runtime's provider.+3. Your **org default** BYO credential for that provider.+4. **Managed**, if your org has no BYO default — so a new org runs Managed out of the box.-If neither resolves, the session fails to start with `422 no_credential`.+Only if **none** resolves does the session fail to start: `422 no_credential` (no Managed and no usable key), or `422 managed_unavailable` (Managed selected/defaulted but not yet active for your org).## Rotation@@ -108,7 +130,7 @@ Changing **which** credential an agent uses (a different `credential` id) affect## Shortcut: add a key inline-Once you're set up, you rarely call the credentials API directly. The common path is to pass the key **inline** when you [create an agent](/agent-sessions/agents) — it's stored as a credential (with all of the protections above) and attached to the agent in one call. The provider is inferred from the agent's `model` (`anthropic/…` → Anthropic, `openai/…` → OpenAI).+For the true **no-key** path, use [Managed](#managed-vs-byo) (`credential: "managed"`) — nothing to store. If you're going BYO, you rarely call the credentials API directly: the common path is to pass the key **inline** when you [create an agent](/agent-sessions/agents) — it's stored as a credential (with all of the protections above) and attached to the agent in one call. The provider is inferred from the agent's `model` (`anthropic/…` → Anthropic, `openai/…` → OpenAI).<CodeGroup>diff --git a/docs/agent-sessions/overview.mdx b/docs/agent-sessions/overview.mdxindex 2dc443d7..c565c128 100644--- a/docs/agent-sessions/overview.mdx+++ b/docs/agent-sessions/overview.mdx@@ -37,7 +37,7 @@ Create an agent, start a session, stream its event log, steer it with messages,<Steps><Step title="Define an agent">- Create a reusable `{ name, model, prompt, runtime }` from your backend — `runtime: "claude"` (Anthropic models) or `"codex"` (OpenAI models). Pass your model `key` inline, or reference a saved [credential](/agent-sessions/credentials). ([Agents](/agent-sessions/agents))+ Create a reusable `{ name, model, prompt, runtime }` from your backend — `runtime: "claude"` (Anthropic models) or `"codex"` (OpenAI models). Run **Managed** (`credential: "managed"`, billed to your OpenComputer credits — no key) or pass your own model `key` inline / reference a saved [credential](/agent-sessions/credentials). ([Agents](/agent-sessions/agents))</Step><Step title="Start a session">Start a session with `{ agent, input }`. The agent starts immediately and returns a browser-safe `client_token`.diff --git a/docs/agent-sessions/quickstart.mdx b/docs/agent-sessions/quickstart.mdxindex 8332ac12..7ec20846 100644--- a/docs/agent-sessions/quickstart.mdx+++ b/docs/agent-sessions/quickstart.mdx@@ -19,7 +19,7 @@ OPENCOMPUTER_API_KEY=osb_...ANTHROPIC_API_KEY=sk-ant-...```-<Tip>Grab your OpenComputer API key from [app.opencomputer.dev](https://app.opencomputer.dev). Sessions run the model on your own provider key — Anthropic for the default `claude` runtime.</Tip>+<Tip>Grab your OpenComputer API key from [app.opencomputer.dev](https://app.opencomputer.dev). Sessions run **Managed** (billed to your OpenComputer credits, no key — the default) or on your own provider key (Anthropic for the default `claude` runtime). This quickstart uses a key; for Managed, drop the `key` and pass `credential: "managed"`.</Tip>## 1. Create an agentdiff --git a/docs/agent-sessions/runtimes.mdx b/docs/agent-sessions/runtimes.mdxindex 3ec97772..1c207320 100644--- a/docs/agent-sessions/runtimes.mdx+++ b/docs/agent-sessions/runtimes.mdx@@ -4,12 +4,12 @@ title: "Runtimes"description: "Runtime engine selected per agent"----A **runtime** executes the agent loop: provider SDK, model calls, and tool use. You pick one per agent with `runtime`; it defaults to `claude`. The model is separate configuration, so an agent is a runtime, a `provider/model`, and a matching [credential](/agent-sessions/credentials).+A **runtime** executes the agent loop: provider SDK, model calls, and tool use. You pick one per agent with `runtime`; it defaults to `claude`. The model is separate configuration, so an agent is a runtime, a `provider/model`, and a model source — **Managed** (billed to your OpenComputer credits, no key) or a matching [credential](/agent-sessions/credentials).| Runtime | Models | Credential || --- | --- | --- |-| `claude` | `anthropic/…` (e.g. `anthropic/claude-opus-4-8`) | Anthropic key |-| `codex` | `openai/…` (e.g. `openai/gpt-5-codex`) | OpenAI key |+| `claude` | `anthropic/…` (e.g. `anthropic/claude-opus-4-8`) | Managed, or an Anthropic key |+| `codex` | `openai/…` (e.g. `openai/gpt-5-codex`) | Managed, or an OpenAI key |`model` is passed straight through to the provider, so any model that provider serves works — only the **`provider/` prefix** is validated against the runtime (a bad prefix is rejected at agent create, a model the provider doesn't recognize fails on the first turn). Common choices:diff --git a/docs/agent-sessions/sessions.mdx b/docs/agent-sessions/sessions.mdxindex 1596c88f..c3f9d70b 100644--- a/docs/agent-sessions/sessions.mdx+++ b/docs/agent-sessions/sessions.mdx@@ -10,7 +10,7 @@ A **session** is an [agent](/agent-sessions/agents) run with an append-only [eve## Session flow-1. You create a session from an [agent](/agent-sessions/agents) (and a [model credential](/agent-sessions/credentials) — both required). The session starts immediately.+1. You create a session from an [agent](/agent-sessions/agents). The model runs **Managed** (billed to your credits, no key — the default) or on a [model credential](/agent-sessions/credentials) you supply. The session starts immediately.2. The [runtime](/agent-sessions/runtimes) executes the agent in a sandbox, appending [events](/agent-sessions/events) to the log as it works.3. With nothing left to do, the session goes **idle** and the sandbox **hibernates**.4. A [steer](/agent-sessions/messaging) message wakes it; it resumes with its prior context. Repeat.@@ -81,7 +81,7 @@ Three independent knobs — don't overload one for another:## Limits-Cap a session at create (or default it on the [agent](/agent-sessions/agents)) with `limits: { tokens, turn_seconds, turns }` — a token budget, per-turn wall-clock, and auto-run count. These are runtime limits, not spend controls; model usage is billed by your provider key. Hitting one ends the turn with the matching `yield_reason`.+Cap a session at create (or default it on the [agent](/agent-sessions/agents)) with `limits: { tokens, turn_seconds, turns }` — a token budget, per-turn wall-clock, and auto-run count. These are runtime limits, not spend controls; model usage is billed to your provider key (BYO) or to your OpenComputer credits (Managed). Hitting one ends the turn with the matching `yield_reason`.## Stop a sessiondiff --git a/docs/background-agents/api.mdx b/docs/background-agents/api.mdxindex 0ac9621e..fb1f245d 100644--- a/docs/background-agents/api.mdx+++ b/docs/background-agents/api.mdx@@ -125,7 +125,7 @@ boundary; see [Sessions](/background-agents/sessions#preview-mid-turn-interrupt)## Connections & models```http-POST /v2/connections # { type: "github" | "github_user" | "slack" | "anthropic" | "openai" | "openrouter", ... }+POST /v2/connections # { type: "github" | "github_user" | "slack" | "anthropic" | "openai", ... }GET /v2/connectionsGET /v2/models # aggregated catalog from connected providers```diff --git a/docs/background-agents/models.mdx b/docs/background-agents/models.mdxindex e61c5c3e..cbb33c25 100644--- a/docs/background-agents/models.mdx+++ b/docs/background-agents/models.mdx@@ -24,7 +24,6 @@ Provider-prefixed, provider-native IDs:```anthropic/claude-opus-4-8openai/gpt-5.x-openrouter/qwen-3-coder```OpenComputer adds no model names of its own. Bare IDs are accepted when@@ -51,11 +50,9 @@ that drives it (the planned `opencode` drives all — Preview).```bashoc connect anthropic --api-key sk-ant-...oc connect openai --api-key sk-...-oc connect openrouter --api-key sk-or-...```-Bring your own keys per provider, or use platform billing where available.-One OpenRouter key opens its full multi-lab catalog.+Bring your own keys per provider, or run **Managed** (billed to your OpenComputer credits) where available.As designed, keys never enter agent machines: model traffic flows throughOpenComputer's model gateway, which holds the keys, enforces the configureddiff --git a/docs/background-agents/overview.mdx b/docs/background-agents/overview.mdxindex 039d4499..0a876cc0 100644--- a/docs/background-agents/overview.mdx+++ b/docs/background-agents/overview.mdx@@ -59,7 +59,7 @@ unattended work.last push.- Models are addressed `provider/model` and switched with one command —effective on the next call within a provider, on the next turn across- providers. Bring your own keys, including OpenRouter.+ providers. Bring your own keys, or run Managed (billed to your credits).- Agents hold no tokens. The platform opens PRs and posts comments on theirbehalf, attributed to the requesting user.- Sessions are two-way. Talk to an agent in a Slack thread, watch it work, anddiff --git a/docs/images/background-agents-architecture.svg b/docs/images/background-agents-architecture.svgindex eb7d1ae6..6cafd0a7 100644--- a/docs/images/background-agents-architecture.svg+++ b/docs/images/background-agents-architecture.svg@@ -71,7 +71,7 @@<text x="758" y="105" font-size="10" fill="#6b6b6b">applies the configured model</text><text x="758" y="120" font-size="10" fill="#7c7aae">records requests + responses</text><text x="758" y="135" font-size="10" fill="#6b6b6b">holds provider keys</text>- <text x="758" y="153" font-size="9" fill="#9a9a9a">Anthropic · OpenAI · OpenRouter</text>+ <text x="758" y="153" font-size="9" fill="#9a9a9a">Anthropic · OpenAI</text><!-- Runtime -> Sandbox --><line x1="585" y1="220" x2="585" y2="266" stroke="#9a9a9a" stroke-width="1.25" marker-end="url(#ah)"/>diff --git a/sdks/typescript/README.md b/sdks/typescript/README.mdindex 2415b302..19243ba5 100644--- a/sdks/typescript/README.md+++ b/sdks/typescript/README.md@@ -44,7 +44,8 @@ const agent = await oc.agents.create({runtime: "claude", // or "codex"model: "anthropic/claude-opus-4-8",prompt: "Review the diff. Run tests. Explain risks.",- key: process.env.ANTHROPIC_API_KEY!, // sealed; never enters the sandbox+ credential: "managed", // run via OpenComputer, billed to credits — no key+ // …or bring your own: key: process.env.ANTHROPIC_API_KEY! (sealed; never enters the sandbox)});// Per request — hand off durable work, route the callback via metadata:@@ -67,7 +68,7 @@ if (delivery.type === "turn.completed") {### Credentials-Sessions run on **your** model-provider key (Anthropic for `claude`, OpenAI for `codex`). The inline `key` above stores one and attaches it to the agent; manage them directly to reuse a key across agents, set an org default, or rotate/remove:+Sessions run **Managed** (via OpenComputer, billed to your credits — `credential: "managed"`, no key, the default for new orgs) or on **your own** model-provider key (Anthropic for `claude`, OpenAI for `codex`). An inline `key` stores one and attaches it to the agent; manage keys directly to reuse one across agents, set an org default, or rotate/remove:```typescriptawait oc.credentials.create({ provider: "anthropic", key: process.env.ANTHROPIC_API_KEY!, name: "prod", isDefault: true });@@ -76,7 +77,7 @@ await oc.credentials.setDefault({ credential: creds[0].id });await oc.credentials.delete(creds[0].id);```-Or reference one by id when creating an agent: `oc.agents.create({ …, credential: "cred_…" })`. A credential is **required** — a session with no resolvable key fails with `422 no_credential`. Full guide: [Credentials](https://docs.opencomputer.dev/agent-sessions/credentials).+Or reference one by id when creating an agent: `oc.agents.create({ …, credential: "cred_…" })`. A key isn't required — `credential: "managed"` needs none; a session fails with `422 no_credential` only when it resolves to neither Managed nor a usable key. Full guide: [Credentials](https://docs.opencomputer.dev/agent-sessions/credentials).## Sandbox webhooks (Preview)