Liking cljdoc? Tell your friends :D

jj.bettong.usage

Token accounting. Every model response carries a usage block; the agent adds them up across the run so you can see what a task cost.

Token accounting. Every model response carries a usage block; the agent adds
them up across the run so you can see what a task cost.
raw docstring

addclj

(add a b)

Sums two usage maps field by field.

Sums two usage maps field by field.
raw docstring

cache-hit-rateclj

(cache-hit-rate {:keys [prompt-tokens cache-hit-tokens]})

The share of prompt tokens the provider served from its cache, 0.0 to 1.0. nil when nothing has been sent yet.

The share of prompt tokens the provider served from its cache, 0.0 to 1.0.
nil when nothing has been sent yet.
raw docstring

costclj

(cost usage prices)

What a run cost, given prices in currency per million tokens:

{:input 0.28 :output 0.42} ; flat {:input 0.28 :output 0.42 :cache-hit 0.028} ; cheaper cached prompt tokens

Prices change and differ per model, so the harness holds none - pass your provider's current numbers. Returns nil when no prices are given.

What a run cost, given prices in currency per million tokens:

  {:input 0.28 :output 0.42}                  ; flat
  {:input 0.28 :output 0.42 :cache-hit 0.028} ; cheaper cached prompt tokens

Prices change and differ per model, so the harness holds none - pass your
provider's current numbers. Returns nil when no prices are given.
raw docstring

normalizeclj

(normalize usage)

Turns an API usage block into our keys. DeepSeek reports cache hits and misses separately (a hit is billed cheaper); other OpenAI-compatible providers omit them, and missing fields simply stay zero.

Turns an API usage block into our keys. DeepSeek reports cache hits and misses
separately (a hit is billed cheaper); other OpenAI-compatible providers omit
them, and missing fields simply stay zero.
raw docstring

of-messageclj

(of-message message)

The usage jj.bettong.llm/chat stashed on the message it returned. A stubbed chat-fn carries none, which still counts as one request.

The usage `jj.bettong.llm/chat` stashed on the message it returned. A stubbed
chat-fn carries none, which still counts as one request.
raw docstring

summaryclj

(summary {:keys [requests prompt-tokens completion-tokens total-tokens
                 cache-hit-tokens]
          :as usage})

One line worth printing at the end of a run.

One line worth printing at the end of a run.
raw docstring

zeroclj

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close