APIBeta

Sessions & operations

Budget sessions, API keys, orders, credits, and resumable streams.

Owner
Developer Experience
Version
api-2026.07
Verified
2026-07-13

Operations are the controls around inference: give an agent a bounded budget, issue a revocable key, submit work for later, and recover a stream after a network interruption.

Choose an operating model

PatternUse it whenWhat is bounded
Prepaid credit keyProduction services and agentsUnified API balance plus per-key budget
Per-request x402One-off calls and no-prefund integrationsEach request's price
Budget sessionAn agent makes several related callsSession budget and expiry
Durable taskWork must survive process, tab, or network lossSteps, aggregate spend, leases, effects, and retention
API keyBackend services need unattended accessKey budget and revocation
Patient orderLatency is flexible and price matters mostOrder limit and expiry

Budget sessions

A session turns a series of requests into one explicit spending envelope. There is no create endpoint: the first completions call that carries routing.session_id opens the session, and its x402 authorization funds the budget. The router returns a session token in the x-session-token header; send it on subsequent calls and the remaining balance is exposed in response headers. Close the session when the workflow ends so the final settlement is explicit.

session-aware SDK flowbudgeted
const session = omnious.session({
  model: "auto",
  budgetUsd: 1,
});

const answer = await session.ask("Summarize the latest market move.");
console.log(answer.content);
console.log(session.remainingUsd());
EndpointPurposeCredential
POST /v1/chat/completions with routing.session_idFirst turn opens the session; the x402 authorization funds its budgetx402
GET /v1/sessions/:idRead session balance and statesession token
POST /v1/sessions/:id/closeClose a session and settle its remaindersession token
session safetyTreat the session token like a short-lived credential. Keep it server-side, set a budget that matches the workflow, and close sessions that are no longer needed.

Durable tasks

A durable task moves execution truth out of a special UI and into the router. The normal chat and SDK share one ordered event log, renewable worker lease, latest checkpoint, verification gate, and write-ahead effect receipts. If a worker disappears after starting an external write, the next worker sees an unresolved effect and blocks for reconciliation instead of guessing and submitting it twice.

managed long-running taskSDK
const { task, result } = await omnious.runTask({
  goal: "Implement the change, run the tests, and verify the result",
  maxSteps: 100,
  maxBudgetUsdc: 2_000_000,
  retentionHours: 24 * 7,
}, { model: "auto", tools: true, maxToolRounds: 100 });

// Store this capability in your secret store. A replacement worker can
// reconstruct the handle and continue from the latest checkpoint.
console.log(task.id, task.token, result.content);

World-class harness behavior comes from separating execution from acceptance. Criteria are immutable once installed. Completion requires a router-produced verification record derived from durable events, exactly-once effects, resolved approvals, budget counters, and the latest content-addressed workspace. A client-authoredverification.passed event cannot satisfy a task that has an acceptance contract.

accept, snapshot, verify, and exportCLI
# Freeze success criteria before execution
omnious task acceptance task_... --token tsk_... --file acceptance.json

# Persist/fork the runnable artifact, then grade durable outcomes
omnious task snapshot task_... --token tsk_... --file workspace.json
omnious task verify task_... --token tsk_... --result-file result.json
omnious task trace task_... --token tsk_... --otlp
EndpointPurposeCredential
PUT /v1/tasks/:id/acceptanceFreeze a deterministic and optional model-review rubrictask capability
POST /v1/tasks/:id/workspace-snapshotsStore a content-addressed runnable workspacetask capability
POST /v1/tasks/:id/workspace-snapshots/:snapshot/forkFork an artifact while preserving lineagetask capability
POST /v1/tasks/:id/verifyGrade events, effects, budgets, approvals, output, and artifactstask capability
GET /v1/tasks/:id/trace/otlpExport redacted OpenTelemetry-shaped spanstask capability
GET /v1/evals/suitesRead the fixed harness regression suitepublic
POST /v1/evals/context/optimizeTune context policy offline from redacted tracesAPI or credit key
POST /v1/evals/runsCreate a governed, wallet-owned evaluation runAPI or credit key

Subjective criteria use a separately authenticated evaluator identity; the task owner cannot submit its own review. Evaluation runs grade capability, crash recovery, prompt-injection resistance, financial approvals, source grounding, context resolution, semantic retry control, answer shape, bounded cost, and termination. The offline optimizer sweeps explicit policy candidates over redacted trace metrics; it never changes a live customer turn. Trial records retain assertions and metrics rather than private prompts.

Task capabilities are returned once and stored only as hashes by the router. The default retention window is seven days (configurable from one hour to 30 days); DELETE /v1/tasks/:id removes the run, events, checkpoints, effects, and approvals immediately.

recovery boundaryA checkpoint can replay model context and completed effect results. An effect that is only marked started is deliberately ambiguous: inspect the external system, resolve its receipt, then resume the task.

API keys for services

Create a spend-capable key for controlled, unattended workloads. Fund the wallet's credits once, give each service its own label and budget, and send that key as x-credit-key. Each request is then one call; the router reserves the worst case and captures metered actuals. Never put a credit key in browser code, a mobile bundle, or a public repository. A normal x-api-key is attribution-only.

create and inspect a key
# Create a key after signing the request with the keys wallet
curl -X POST "$ROUTER_URL/v1/keys" \
  -H "x-keys-wallet: $WALLET" \
  -H "x-keys-sig: $SIGNATURE" \
  -H "content-type: application/json" \
  -d '{"label":"production-agent","budget_usdc":"50"}'

# Use the returned key on a request
curl "$ROUTER_URL/v1/keys/usage" \
  -H "x-api-key: $OMNIOUS_API_KEY"
EndpointPurposeCredential
POST /v1/keysCreate a scoped API keykeys wallet signature
GET /v1/keysList keys owned by the keys walletkeys wallet signature
DELETE /v1/keys/:idRevoke a keykeys wallet signature
GET /v1/keys/usageUsage and budget countersAPI key
POST /v1/credits/depositsFund prepaid credits once (spendable on inference, not currently withdrawable)x402
GET /v1/credits/balanceRead unified API balancecredit key

Patient orders

Patient orders let the market work over a wider latency window when the request can wait.

EndpointPurposeCredential
POST /v1/ordersSubmit a patient or deferred requestAPI key

Retries and resumable streams

  • Send an Idempotency-Key when a client may retry a paid completion.
  • Persist x-request-id and the payment response for support and reconciliation.
  • For a dropped stream, reconnect with GET /v1/streams/:id and its x-stream-token.
  • Use POST /v1/streams/:id/stop when the caller cancels; do not abandon open work.
production ruleKeep credentials and signing keys in your server environment, give each worker the smallest budget it needs, and alert on unexpected spend, repeated 402s, or a rising rate of 5xx responses.