openRouterCostUsd
function openRouterCostUsd(usage, scope?): number | undefined;Defined in: core/src/providers/openrouter-billing.ts:37
What an OpenRouter call cost, in USD, or undefined when it did not say.
Nothing has to ask for it. OpenRouter’s usage-accounting docs (read
2026-09-26) say every response now carries the full usage record, cost
included, on the last frame of a stream, and that usage: { include: true }
is deprecated and does nothing. Measured the same day: a streamed call and a
plain one, neither sending the flag, both came back with usage.cost, the
stream on its last frame. So the request does not send it.
With the caller’s own provider key (BYOK), cost is only OpenRouter’s fee.
The inference is billed to the caller’s provider account and arrives as
cost_details.upstream_inference_cost, so the call cost the two together.
Without that second figure there is no whole bill to report, and the
caller’s rate prices the call instead.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
usage |
OpenRouterBill |
undefined |
scope |
"total" | "reported" |
"total" |
Returns
Section titled “Returns”number | undefined