Class CostEstimator
- Namespace
- Emissary
- Assembly
- Emissary.dll
Computes the monetary cost of agent runs from token usage and a registered price table. Cache reads and writes are billed at their own rates, so a cache-heavy run costs far less than its raw input-token count suggests.
public sealed class CostEstimator
- Inheritance
-
CostEstimator
- Inherited Members
Methods
Estimate(string, AgentUsage)
Estimates the cost of the given usage for a model.
public decimal Estimate(string model, AgentUsage usage)
Parameters
modelstringThe model id, which must have been registered.
usageAgentUsageThe accumulated usage (e.g. Usage).
Returns
Exceptions
- KeyNotFoundException
No pricing is registered for the model.
Register(string, ModelPricing)
Registers (or overrides) the price table for a model.
public CostEstimator Register(string model, ModelPricing pricing)
Parameters
modelstringThe model id, e.g. "claude-opus-5".
pricingModelPricingThe per-million-token rates.
Returns
TryEstimate(string, AgentUsage, out decimal)
Attempts to estimate the cost; returns false if the model is unregistered.
public bool TryEstimate(string model, AgentUsage usage, out decimal cost)
Parameters
modelstringThe model id.
usageAgentUsageThe accumulated usage.
costdecimalThe estimated cost when the model is registered.