Table of Contents

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

model string

The model id, which must have been registered.

usage AgentUsage

The accumulated usage (e.g. Usage).

Returns

decimal

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

model string

The model id, e.g. "claude-opus-5".

pricing ModelPricing

The per-million-token rates.

Returns

CostEstimator

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

model string

The model id.

usage AgentUsage

The accumulated usage.

cost decimal

The estimated cost when the model is registered.

Returns

bool