Imp.Core.LMResponse (Imp v0.12.1)

Copy Markdown View Source

Provider-neutral LM response: normalized outputs, usage, cost, and raw data.

cost is what the provider says it charged for this call, in USD, as a non-negative float, or nil when the provider reported no charge. nil means the charge is unknown, not that the call was free. OpenRouter reports its charge, unasked, as the "cost" field of its usage object; ReqLLM carries that field through unchanged, and Imp reads it from there. A provider whose response carries no charge — the Anthropic, OpenAI and Google APIs called directly among them — gives a nil cost. On an OpenRouter call made with the caller's own provider key ("is_byok"), cost is OpenRouter's fee plus the upstream charge it reports in "cost_details", and nil when that upstream charge is missing. An LM client other than ReqLLM reports its charge as :cost in its response metadata.

estimated_cost is ReqLLM's estimate for the call: the reported token counts priced from its model catalog, as a non-negative float, or nil when the catalog has no price for the model. It is a different number from the charge whenever prices have changed, the provider routed to an endpoint with other prices, or the provider prices caching and reasoning differently from the catalog, so a host that falls back on it when cost is nil is choosing to count an estimate as spend.

Either figure may arrive as a bare number, a string, a Decimal or a breakdown map carrying a total, and Imp reads the number out of each, so a host reading a call's money never has to learn a provider library's private shape.

billing is the breakdown behind estimated_cost — ReqLLM's catalog line items and input, output and reasoning splits — untouched, when there is one, and nil otherwise. Its shape belongs to ReqLLM, so it is evidence to inspect rather than a contract to depend on.

Summary

Types

t()

@type t() :: %Imp.Core.LMResponse{
  billing: map() | nil,
  cost: float() | nil,
  estimated_cost: float() | nil,
  metadata: map(),
  outputs: list(),
  raw: term(),
  usage: map()
}