Docs target current release v0.5.0.v0.6.0 is in development

tine cost

Since version 0.3, opentine normalizes provider usage, records a known cost subtotal for compatibility, and exposes explicit billing completeness plus the run's budget state.

Terminal
tine cost result.tine

Machine-readable cost and budget state

Terminal
tine cost result.tine --json

In v0.5, --json emits exactly one object with token and cost totals, per-model and per-kind breakdowns, the declared budget, recorded budget state, and over_budget. A recorded breach emits "over_budget": true and exits 1 even though the result object is valid. A missing or unreadable run produces a human-readable nonzero error instead of partial JSON.

Budgets in Python

budget.py
1from opentine import Agent, Budget
2from opentine.models.ollama import Ollama
3
4agent = Agent(
5    model=Ollama("qwen3"),
6    budget=Budget(
7        max_cost=0.50,
8        max_steps=20,
9        strict_cost=True,
10        on_breach="stop",
11    ),
12)
13run = agent.run_sync("Complete the task within budget")
14
15print(run.total_tokens)
16print(run.cost_breakdown())

Choose stop when an inspectable partial artifact is acceptable. Choose raise when budget exhaustion must be a hard caller-visible failure. strict_cost=True stops before the next model call after any hosted price or observed usage dimension becomes indeterminate.

Billing status

  • complete: every observed dimension has a pinned rate.
  • partial: a known subtotal exists, but at least one dimension is unpriced.
  • unknown: no exact amount can be determined.
  • unmetered: no metered API charge is configured, although infrastructure can still cost money.

The legacy numeric cost field is the known USD subtotal. It can be nonzero while billing.amount_usd is null. Provider usage is an estimate input, not a final invoice. See usage and pricing.