# Reasoning and usage

Stream thinking blocks, and report token usage and cost on every response.

## Reasoning [#reasoning]

```ts
reply: [
  reasoning("The user wants a refund. I should look up the order first."),
  toolCall("lookupOrder", { id: "A-1042" }),
];
```

Reasoning streams in each format's native shape: reasoning summary events on the OpenAI Responses API, `thinking` blocks with a signature on Anthropic when the request enables thinking, and `reasoning-start`, `reasoning-delta` and `reasoning-end` parts on the AI SDK UI stream. Chat Completions has no reasoning content, so there it only counts toward `completion_tokens_details.reasoning_tokens`.

## Usage [#usage]

Every response reports token usage. By default LoremLLM counts tokens in the request and the reply with the tokenizer for the reported model.

Override it when a test needs exact numbers. Field names follow the AI SDK's `LanguageModelUsage`, and each endpoint maps them to its own: `prompt_tokens` and `completion_tokens` on Chat Completions, `input_tokens`, `output_tokens` and `cache_read_input_tokens` on Anthropic.

```ts
reply: [text("Done."), usage({ inputTokens: 1200, outputTokens: 18, cachedInputTokens: 1000 })];
```

## Cost [#cost]

Usage includes a cost estimate based on the reported model's public price list. It appears in the inspector and in the AI SDK finish part's metadata. Set `pricing` on a mock to use your own rates:

```ts
defineMock("support-bot", {
  model: "gpt-4.1",
  pricing: { inputPerMillion: 2, outputPerMillion: 8 },
});
```

Use it to test budget limits and cost dashboards without spending anything.