LLM

Test which pricing definition matches a model name and calculate cost

Simulates the pricing lookup for a given model name and optional usage data, returning the matched definition, selected tier, and cost breakdown. With match_pattern, also lists the known models that pattern would price if saved as a rule in this organization.

post/api/{org_id}/llm/models/test

Request

Path parameters

org_idstring required

Organization name

Request body

attributesobject

Optional span attributes (e.g. {"openai.response.service_tier": "flex"}) for tier rules.

match_patternstring nullable

An unsaved rule pattern to preview. When set, the response lists in captured_models every known model this pattern would price if it were saved in this org. The model_name test is unaffected and still runs against the saved rules.

model_namestring

The model name to test (e.g. "gpt-4o", "claude-opus-3-5"). Empty skips the single-name test, e.g. when only previewing match_pattern.

rule_idstring nullable

Id of the rule being edited. It is left out of the preview, so its saved pattern does not compete with the edited one.

timestampinteger nullable

Optional span timestamp in microseconds. When provided, only definitions whose valid_from <= timestamp are considered, and tiers restricted to recurring UTC time-of-day windows (peak / off-peak) are resolved against it.

usageobject

Optional token counts keyed by usage type (e.g. {"input": 1000, "output": 500}). When provided, cost is calculated using the matched pricing definition.

Response

Success

costsobject required

Per-usage-key costs (excluding "total").

match_kind'approximate' | 'exact'

How a pricing pattern matched a model name.

Ordered so that Exact > Approximate: when several patterns of the same source match, an exact match wins.

tierstring nullable

The name of the selected pricing tier, or null if no definition matched.

tier_indexinteger nullable

Index of the selected tier in matched.tiers, which stays unambiguous when names repeat.

total_costnumber double required

Sum of all per-key costs.

Changes

No recorded changes to this operation across all 1 revision of this API.