Added
- Bring your own LLM cost.
capture(name, fn, { cost: { input, output } | { total } })sets the
cost (USD) of every LLM-call span inside the capture (never the capture's own wrapper span).
new Latitude({ pricing: { "<provider>/<model>": { inputPer1M, outputPer1M } } })prices LLM
calls from their token counts, andnew Latitude({ costResolver })letscostResolver(usage)
return a cost orundefinedto fall back.setLlmCost(span, { input, output, total })sets the
cost of one span. Precedence:setLlmCost>capturecost >costResolver>pricing>
Latitude's server-side pricing. - Where the SDK sets cost it writes
gen_ai.usage.input_cost,gen_ai.usage.output_costand
gen_ai.usage.total_costpluslatitude.cost.source="user", replacing any cost the
instrumentation wrote on that span.totaldefaults toinput + output, atotal-only cost
drops the instrumentation's input/output costs, and an explicit0is honoured. Cost is applied
at export through an exporter wrapper, so other processors on a shared provider see the span
unchanged. New exports:setLlmCost,ATTRIBUTES(now includingcostInput/costOutput/
costTotal/costSource),COST_SOURCE_USERand theLlmCost,LlmUsage,ModelPricing
andCostResolvertypes. LLM calls, provider, model and token counts are read from
OpenTelemetry GenAI, OpenInference (including CrewAI'sAGENTspan), OpenLLMetry and Vercel AI
SDK (ai.model.*,ai.usage.*) attributes, and cost is resolved when each span ends, before
redaction.