Skip to main content
Use traces to understand what ran, evaluations to check whether it was correct, and cost accounting to estimate reported usage. These answer different questions. The quality-gate project provides a complete runnable application that retains reports and JSONL traces.

Observe one run and estimate its cost

Host function: pass a configured model, its current per-1,000-token prices, and the input. Install matching @agentium/core and @agentium/observability, plus the selected provider dependency. The function owns the Agent and observer; a live provider makes a real request.
Expect a console trace and a return value containing reported tokens, the cost estimate, and metrics. Default tracing excludes prompt, tool, and output content. If the model reports no usage, do not interpret a zero estimate as a free request. The explicit price key follows model.modelId, so changing models does not accidentally retain the previous model’s lookup key. The caller must update the values too. The v4 bundled price table predates the current text models in these docs.

Supply matching prices

ModelPricing uses dollars per 1,000 tokens. Prices listed per million must be divided by 1,000. For example, the standard uncached text rates checked on October 4, 2026 were: These are dated example rates from the OpenAI model catalog. Recheck your provider, model, service tier, caching, and audio/reasoning billing when adapting them. See example model choices and the pricing type.

Add a budget with the right expectation

Configuration factory: the caller attaches this tracker to the Agent(s) it wants to account for. The model ID and prices must match those executions.
Budget checks use known usage at their execution boundaries. They cannot retract a request already accepted by a provider or guarantee a maximum invoice. Use model output limits, bounded tool rounds, host concurrency, and provider controls as well. See cost auto-stop for in-progress checks. When sharing a tracker, use stable user/session identifiers and choose the lifetime of accumulated entries deliberately. An in-memory tracker is not your billing ledger.

Choose an evidence destination

Delivery through a bounded exporter is not an authoritative audit ledger. Flush owned telemetry after active runs and Agent cleanup settle; the host owns shutdown of borrowed exporters or SDK providers according to their contract.

More patterns

Use exporter selection for all destinations, capture settings for bounded content capture, evaluation patterns for answer quality, and operations for limits and drain.