Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.output.ai/llms.txt

Use this file to discover all available pages before exploring further.

This release has two breaking changes:
  1. The llm:call_cost hook event was renamed to cost:llm:request;
  2. The cost object in events and LLM responses has a new format.

Migration steps

Event renaming

Update each hook that listens for llm:call_cost to use cost:llm:request:

Before

import { on } from '@outputai/core/hooks';

on( 'llm:call_cost', async ( { modelId, cost, usage } ) => {
  ...
} );

After

import { on } from '@outputai/core/hooks';

on( 'cost:llm:request', async ( { modelId, cost, usage } ) => {
  ...
} );

Cost payload

On the @outputai/llm module, the cost field in both the .generateText() response and the cost:llm:request event has a new format:

Before

{
  "total": 0.002341,
  "components": {
    "input": { "value": 0.001302 },
    "cachedInput": { "value": 0 },
    "output": { "value": 0.001039 },
    "reasoning": { "value": 0.00027 }
  }
}

After

{
  "total": 0.002341,
  "components": [
    { "name": "input_tokens", "value": 0.001302 },
    { "name": "input_cached_tokens", "value": 0 },
    { "name": "output_tokens", "value": 0.001039 },
    { "name": "reasoning_tokens", "value": 0.00027 }
  ]
}
Note: components used to be an object; it is now an array.