ResponseMetrics

A response's numbers on one line: time to first token, total time, tokens in and out, reasoning, cost. Empty before a response; while one streams it shows what is known so far.

View source
First token
420 ms
Total
3.14 s
Tokens
1,204 in · 856 out
Reasoning
312
Cost
$0.009725
import { ResponseMetrics, formatLatency } from "@logicplanes/kaeso-ui/playground";

Props

  • cost
    string | null

    USD as a decimal string, shown with its own decimals (two at least, six at most): "0.004213" reads "$0.004213", "1.2311" reads "$1.2311", zero reads "$0" and less than a millionth reads "< $0.000001".

  • costKnown
    boolean = true

    False when the model has no price for what it made: the cost reads "Unknown" (true by default).

  • duration
    number | null

    Milliseconds from sending to the last token.

  • formatCost
    ((cost: string) => string)

    Writes cost in place of the dollar format, such as in another currency at the day's rate.

  • inputTokens
    number | null

    The tokens sent, once known.

  • live
    boolean = false

    A response is arriving: Total counts up from startedAt, and an unknown cost isn't called Unknown yet.

  • outputTokens
    number | null

    The tokens received, once known.

  • reasoningTokens
    number | null

    Of the output tokens, those spent reasoning. Shown when the provider reported them.

  • size
    "md" | "sm" = sm

    The text size.

  • startedAt
    number

    When the request was sent (Date.now()): while live, Total counts up quietly, in tenths of a second and in whole seconds past ten, until duration arrives.

  • timeToFirstToken
    number | null

    Milliseconds from sending to the first token.