@outputai/http and @outputai/llm cost tracking changes in v0.5.0.
What changed
addRequestCostnow accepts a numeric total instead of aRequestCostobject.- The
RequestCosttype is removed. - The
cost:http:requestevent now receives an HTTP request cost attribute instead of{ requestId, url, cost }. - LLM response
.costis now an LLM usage attribute instead of{ total, components }. - LLM usage entries only include available, finite dimensions; missing dimensions are omitted.
- Missing LLM costs are returned as
null, not as cost objects withtotal: nullandmessage. - The
cost:llm:requestevent now receives the LLM usage attribute instead of{ modelId, cost, usage }.
Migration steps
Update addRequestCost
Pass the total request cost directly.
Before
After
Remove RequestCost imports
The RequestCost object shape is no longer part of the public API.
Before
After
Update cost:http:request hooks
The event payload is now the HTTP request cost attribute.
Before
After
Update LLM response cost handling
The.cost property on generateText() responses and streamText() onFinish responses is now an LLM usage attribute.
Before
After
response.cost is null.
Handle missing LLM costs
When LLM pricing cannot be loaded or the model is missing from the pricing table, Output no longer returns a cost object withtotal: null and message.
Before
After
cost:llm:request event or LLM usage trace attribute is emitted when cost is missing.
Handle omitted LLM usage fields
Cost usage entries now include only the dimensions that are available and priced.Before
After
usage[].type values:
Update cost:llm:request hooks
The event payload is now the LLM usage attribute.
Before
After
Cost attribute reference
HTTP and LLM cost payloads are now trace attributes. Hook payloads includeworkflowId; workflow result attributes are nested under a result that already has workflowId and runId, so they do not repeat the workflow ID.
HTTP request cost hook payload
LLM usage cost hook payload
Each
usage entry includes type, ppm, amount, and total. Only available, finite usage dimensions are included.
Checklist
- Replace every
addRequestCost(response, { total, components })call withaddRequestCost(response, total). - Remove
RequestCostimports and annotations. - Update
cost:http:requesthook handlers to readtotaldirectly from the payload. - Remove any logic that expected HTTP cost
components; HTTP request costs are now a single total value. - Replace LLM
response.cost.componentsreads withresponse.cost?.usage. - Handle
response.cost === nullwhen pricing cannot be computed; do not expect a cost object withtotal: nullandmessage. - Update
cost:llm:requesthook handlers to read the LLM usage attribute payload directly.