Skip to main content
This guide covers the @outputai/http and @outputai/llm cost tracking changes in v0.5.0.

What changed

  • addRequestCost now accepts a numeric total instead of a RequestCost object.
  • The RequestCost type is removed.
  • The cost:http:request event now receives an HTTP request cost attribute instead of { requestId, url, cost }.
  • LLM response .cost is 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 with total: null and message.
  • The cost:llm:request event 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

When pricing cannot be computed, 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 with total: null and message.

Before

After

No 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

Use these 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 include workflowId; 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 with addRequestCost(response, total).
  • Remove RequestCost imports and annotations.
  • Update cost:http:request hook handlers to read total directly from the payload.
  • Remove any logic that expected HTTP cost components; HTTP request costs are now a single total value.
  • Replace LLM response.cost.components reads with response.cost?.usage.
  • Handle response.cost === null when pricing cannot be computed; do not expect a cost object with total: null and message.
  • Update cost:llm:request hook handlers to read the LLM usage attribute payload directly.