floe-guard 0.13.2 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/livekit.cjs +18 -0
- package/dist/adapters/livekit.cjs.map +1 -1
- package/dist/adapters/livekit.js +1 -1
- package/dist/adapters/retell.cjs +18 -0
- package/dist/adapters/retell.cjs.map +1 -1
- package/dist/adapters/retell.js +1 -1
- package/dist/adapters/vapi.cjs +18 -0
- package/dist/adapters/vapi.cjs.map +1 -1
- package/dist/adapters/vapi.js +1 -1
- package/dist/{chunk-TAK6I7CN.js → chunk-HDZAI5Y3.js} +19 -1
- package/dist/{chunk-TAK6I7CN.js.map → chunk-HDZAI5Y3.js.map} +1 -1
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/cost_map.json +18 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/retell.ts","../../src/errors.ts","../../src/gates.ts","../../src/cost_map.json","../../src/voice-pricing.ts"],"sourcesContent":["/**\n * Retell custom-LLM WebSocket adapter (optional peer: the `ws` server your custom\n * LLM already runs — this adapter never opens or hard-depends on it).\n *\n * Retell's custom LLM runs over a WebSocket (docs.retellai.com/api-references/\n * llm-websocket). Retell sends interaction events to your server; the billable one\n * is **`response_required`** (an auto-incrementing `response_id` plus the running\n * `transcript`), and its twin **`reminder_required`**. Your server streams back\n * **`response`** events — many partials per turn — ending with `content_complete:\n * true`. A NEW `response_required` with a higher `response_id` means the caller\n * barged in: it **interrupts** the turn in flight, which never reaches\n * `content_complete`.\n *\n * Like the LiveKit adapter, a Retell call has no single call site to wrap: turns\n * fire for the life of the socket. The two enforcement points are the arrival of a\n * `response_required` (before the LLM call, so a turn is admitted or blocked before\n * its TTS/telephony spend piles on) and the turn's real token usage (after\n * `content_complete`). {@link RetellBudgetGuard} holds the reservation across both,\n * keyed by `response_id`, and releases it when a newer turn interrupts.\n *\n * import { BudgetGuard } from \"floe-guard\";\n * import { RetellBudgetGuard } from \"floe-guard/adapters/retell\";\n *\n * const guard = new BudgetGuard(1.0, {\n * priceOverrides: {\n * \"gpt-4o-mini\": { inputCostPerToken: 0.15e-6, outputCostPerToken: 0.6e-6 },\n * },\n * });\n * const budget = new RetellBudgetGuard(guard, {\n * model: \"gpt-4o-mini\",\n * sttModel: \"deepgram-nova-3\",\n * ttsModel: \"elevenlabs-flash-v2.5\",\n * telephony: \"twilio-us-inbound-local\",\n * });\n *\n * // In your custom-LLM WS message handler:\n * ws.on(\"message\", async (raw) => {\n * const event = JSON.parse(raw);\n * if (event.interaction_type === \"response_required\" ||\n * event.interaction_type === \"reminder_required\") {\n * const turn = budget.beginTurn(event); // reserve before the LLM call\n * if (!turn.admitted) { // budget exhausted\n * ws.send(JSON.stringify(\n * budget.response(event.response_id, \"I'm out of budget — wrapping up.\",\n * { complete: true, endCall: true })));\n * return;\n * }\n * const { text, usage } = await callYourLlm(event.transcript); // your LLM\n * ws.send(JSON.stringify(budget.response(event.response_id, text, { complete: true })));\n * budget.settleTurn(event.response_id, usage); // settle real token usage\n * }\n * });\n *\n * ## Why a WebSocket adapter, not a request wrapper\n *\n * The custom LLM sees only the **LLM leg** (the tokens behind each `response`). STT,\n * TTS and telephony are billed by Retell/the carrier and never cross this socket, so\n * they are metered **explicitly** — call {@link RetellBudgetGuard.meterStt} /\n * {@link RetellBudgetGuard.meterTts} / {@link RetellBudgetGuard.meterTelephony} from\n * wherever those durations are known (webhook, call-ended event). Each is priced\n * from the bundled voice cost map when you name the vendor, or a per-unit override\n * which wins over the map; a leg with neither is left un-metered (the token-only\n * contract), and a named vendor the map cannot price fails closed\n * ({@link UnpriceableVoiceError}).\n *\n * Scope is strictly **pre-turn / pre-call admission plus per-turn settlement**.\n * There is no mid-call intervention: an admitted turn runs to `content_complete`;\n * nothing here cuts a turn off partway. The only release is the interrupt Retell\n * itself signals (a newer `response_id`) or an explicit {@link RetellBudgetGuard.close}\n * on call teardown.\n */\n\nimport { BudgetExceeded } from \"../errors.js\";\nimport * as gates from \"../gates.js\";\nimport type { BudgetGuard, ReservationHandle } from \"../guard.js\";\nimport { priceVoiceLeg } from \"../voice-pricing.js\";\n\n/** One entry of a Retell `transcript` (loosely typed — we never read into it). */\nexport interface RetellUtterance {\n readonly role: \"agent\" | \"user\";\n readonly content: string;\n}\n\n/**\n * The Retell interaction events that require a turn. `response_required` is a real\n * user utterance; `reminder_required` fires after silence — both carry an\n * auto-incrementing `response_id` and expect a `response` stream in reply. Typed\n * structurally so a parsed WS message satisfies it with no Retell SDK dependency.\n */\nexport interface RetellResponseRequiredEvent {\n readonly interaction_type: \"response_required\" | \"reminder_required\";\n /** Auto-incrementing turn id; a higher value than the open turn means an interrupt. */\n readonly response_id: number;\n readonly transcript?: readonly RetellUtterance[];\n}\n\n/**\n * A `response` event to stream back to Retell. Emit several partials per turn\n * (`content_complete: false`), then a final one with `content_complete: true`.\n * Build them with {@link RetellBudgetGuard.response}.\n */\nexport interface RetellResponseEvent {\n readonly response_type: \"response\";\n readonly response_id: number;\n readonly content: string;\n readonly content_complete: boolean;\n readonly end_call?: boolean;\n}\n\n/** Real token usage for a settled turn — the LLM leg the socket sees. */\nexport interface RetellTokenUsage {\n readonly promptTokens: number;\n readonly completionTokens: number;\n}\n\n/**\n * The decision {@link RetellBudgetGuard.beginTurn} returns. `admitted: true` means\n * the turn's reservation is held — run the LLM and settle it. `admitted: false`\n * means the budget is spent: send a wrap-up `response` (with `content_complete`) and\n * do not call the LLM; `error` carries the {@link BudgetExceeded} for logging.\n */\nexport type RetellTurnDecision =\n | { readonly admitted: true; readonly responseId: number }\n | { readonly admitted: false; readonly responseId: number; readonly error: BudgetExceeded };\n\nexport interface RetellBudgetGuardOptions {\n /**\n * Model id to settle LLM cost against (Retell's usage payload names no model we\n * rely on). Must be priceable via the bundled cost map or the guard's\n * `priceOverrides`.\n */\n model: string;\n /** Voice-map vendor key for the STT leg (e.g. `\"deepgram-nova-3\"`). */\n sttModel?: string;\n /** Voice-map vendor key for the TTS leg (e.g. `\"elevenlabs-flash-v2.5\"`). */\n ttsModel?: string;\n /** Voice-map vendor key for the telephony leg (e.g. `\"twilio-us-inbound-local\"`). */\n telephony?: string;\n /** Per-second STT override — wins over `sttModel`. Omit both to leave STT un-metered. */\n sttUsdPerSecond?: number;\n /** Per-1k-chars TTS override — wins over `ttsModel`. Omit both to leave TTS un-metered. */\n ttsUsdPer1kChars?: number;\n /** Per-minute telephony override — wins over `telephony`. */\n telephonyUsdPerMinute?: number;\n}\n\n/**\n * One turn's reservation, keyed by `response_id`. `open` means the USD amount is\n * still held on the {@link BudgetGuard}. A settle or an interrupt closes it.\n */\ninterface TurnSlot {\n readonly responseId: number;\n amount: ReservationHandle;\n open: boolean;\n}\n\n/**\n * Enforce a {@link BudgetGuard} ceiling on a Retell custom-LLM socket, one turn at\n * a time: reserve when a `response_required` arrives, settle on real token usage\n * after `content_complete`, release when a newer `response_id` interrupts.\n */\nexport class RetellBudgetGuard {\n private readonly guard: BudgetGuard;\n private readonly model: string;\n private readonly sttModel?: string;\n private readonly ttsModel?: string;\n private readonly telephony?: string;\n private readonly sttUsdPerSecond?: number;\n private readonly ttsUsdPer1kChars?: number;\n private readonly telephonyUsdPerMinute?: number;\n\n /** Open (and just-settled) turns keyed by `response_id`. */\n private readonly slots = new Map<number, TurnSlot>();\n /** The most recently begun turn — the one a newer `response_required` interrupts. */\n private activeResponseId: number | null = null;\n\n constructor(guard: BudgetGuard, options: RetellBudgetGuardOptions) {\n this.guard = guard;\n this.model = options.model;\n this.sttModel = options.sttModel;\n this.ttsModel = options.ttsModel;\n this.telephony = options.telephony;\n this.sttUsdPerSecond = options.sttUsdPerSecond;\n this.ttsUsdPer1kChars = options.ttsUsdPer1kChars;\n this.telephonyUsdPerMinute = options.telephonyUsdPerMinute;\n }\n\n /**\n * Reserve budget for a `response_required` / `reminder_required` turn before its\n * LLM call runs. Returns an admit/block {@link RetellTurnDecision}.\n *\n * A newer `response_id` arriving while a prior turn is still open is Retell's\n * interrupt signal — this releases that prior turn's hold before reserving the new\n * one (its `content_complete` will never arrive). Reserving here is what blocks a\n * turn before its downstream TTS/telephony spend piles on. Calling twice with the\n * same still-open `response_id` is idempotent (no double hold).\n */\n beginTurn(event: RetellResponseRequiredEvent): RetellTurnDecision {\n const responseId = event.response_id;\n\n // Idempotent: this turn already holds a reservation.\n const existing = this.slots.get(responseId);\n if (existing !== undefined && existing.open) {\n return { admitted: true, responseId };\n }\n\n // A newer turn interrupts the prior open turn — free its hold before opening this\n // one. Its usage never settles (no content_complete); a stray late settle for it\n // finds no open slot and records actual usage against a zero reservation.\n this.releaseActive(responseId);\n\n let handle: ReservationHandle;\n try {\n handle = this.guard.reserve(); // throws BudgetExceeded before the turn runs\n } catch (err) {\n if (err instanceof BudgetExceeded) {\n return { admitted: false, responseId, error: err };\n }\n throw err;\n }\n\n this.slots.set(responseId, { responseId, amount: handle, open: true });\n this.activeResponseId = responseId;\n return { admitted: true, responseId };\n }\n\n /**\n * Settle a turn's real token usage after its `content_complete`. Consumes the\n * reservation opened by {@link beginTurn} for this `response_id`; a turn with no\n * open slot (already interrupted, or a settle for an id never begun) records the\n * usage against a zero reservation instead of stealing another turn's hold.\n */\n settleTurn(responseId: number, usage: RetellTokenUsage): void {\n let reserved: ReservationHandle = 0;\n const slot = this.slots.get(responseId);\n if (slot !== undefined) {\n if (slot.open) {\n reserved = slot.amount;\n slot.open = false;\n }\n this.slots.delete(responseId);\n }\n if (this.activeResponseId === responseId) this.activeResponseId = null;\n this.guard.settle(this.model, usage.promptTokens, usage.completionTokens, { reserved });\n }\n\n /**\n * Pre-call admission for Retell's inbound-call webhook, wrapping {@link gates.retell}.\n * On budget exhaustion returns `{ call_inbound: { reject: true } }`; otherwise\n * `{ call_inbound: {...} }` carrying any `admit` overrides (`dynamic_variables`,\n * `metadata`, `override_agent_id`, …).\n *\n * A coarse, non-binding preflight — the binding hard-stop is the per-turn reserve\n * in {@link beginTurn}. Pass `estimatedCallUsd` (e.g. `$/min × expected minutes`)\n * to reject earlier, when the remaining budget can't cover the call.\n */\n admitCall(\n options: { estimatedCallUsd?: number; admit?: Record<string, unknown> } = {},\n ): { call_inbound: Record<string, unknown> } {\n return gates.retell(this.guard, options);\n }\n\n /**\n * Build a `response` event to stream back to Retell. Send partials with\n * `complete: false`, then a final one with `complete: true`; settle the turn's\n * token usage after that final one. Pass `endCall: true` to hang up (e.g. on a\n * budget wrap-up line). A thin convenience — you may build the shape yourself.\n */\n response(\n responseId: number,\n content: string,\n options: { complete?: boolean; endCall?: boolean } = {},\n ): RetellResponseEvent {\n return {\n response_type: \"response\",\n response_id: responseId,\n content,\n content_complete: options.complete ?? false,\n ...(options.endCall ? { end_call: true } : {}),\n };\n }\n\n /**\n * Accrue STT spend for `seconds` of transcribed audio (per-second). The socket\n * never sees the STT leg, so drive this from wherever the duration is known.\n * Priced from the voice map when `sttModel` is set, or the `sttUsdPerSecond`\n * override; returns `null` (no-op) when the leg is unconfigured, and fails closed\n * on a vendor the map cannot price. Returns the USD accrued, if any.\n */\n meterStt(seconds: number): number | null {\n const cost = priceVoiceLeg(\"stt\", seconds, {\n model: this.sttModel,\n override: this.sttUsdPerSecond,\n });\n if (cost !== null) this.guard.recordTool(\"retell-stt\", cost);\n return cost;\n }\n\n /**\n * Accrue TTS spend for `characters` of synthesized speech (per-1k-chars). Priced\n * from the voice map when `ttsModel` is set, or the `ttsUsdPer1kChars` override;\n * returns `null` when unconfigured, and fails closed on an unpriceable vendor.\n */\n meterTts(characters: number): number | null {\n const cost = priceVoiceLeg(\"tts\", characters, {\n model: this.ttsModel,\n override: this.ttsUsdPer1kChars,\n });\n if (cost !== null) this.guard.recordTool(\"retell-tts\", cost);\n return cost;\n }\n\n /**\n * Accrue telephony spend for `minutes` of call time (per-minute). Per-minute\n * accrual, not live line-cutting: the guard meters the leg, it does not cut the\n * phone line mid-call. Priced from the voice map when `telephony` is set, or the\n * `telephonyUsdPerMinute` override; returns `null` when unconfigured, and fails\n * closed on an unpriceable vendor. Returns the USD accrued, if any.\n */\n meterTelephony(minutes: number): number | null {\n const cost = priceVoiceLeg(\"telephony\", minutes, {\n model: this.telephony,\n override: this.telephonyUsdPerMinute,\n });\n if (cost !== null) this.guard.recordTool(\"retell-telephony\", cost);\n return cost;\n }\n\n /**\n * Release any still-open turn's reservation on call teardown (socket close, call\n * ended). A turn that never reached `content_complete` would otherwise leak its\n * hold and shrink `remainingUsd` permanently.\n */\n close(): void {\n for (const slot of this.slots.values()) {\n if (slot.open) this.guard.release(slot.amount);\n }\n this.slots.clear();\n this.activeResponseId = null;\n }\n\n /** Release the active open turn's hold unless it is `exceptId` (the incoming turn). */\n private releaseActive(exceptId: number): void {\n const id = this.activeResponseId;\n if (id === null || id === exceptId) return;\n const slot = this.slots.get(id);\n if (slot !== undefined && slot.open) {\n this.guard.release(slot.amount);\n slot.open = false;\n this.slots.delete(id);\n }\n this.activeResponseId = null;\n }\n}\n","/**\n * Exceptions for floe-guard.\n *\n * Everything derives from {@link FloeGuardError} (the package-root base) so callers\n * can catch the whole family with a single `catch (e) { if (e instanceof FloeGuardError) ... }`.\n *\n * Mirrors `src/floe_guard/errors.py` in the Python package — message formats are\n * kept byte-for-byte identical so both adapters read the same.\n */\n\n/** Base class for every error raised by floe-guard. */\nexport class FloeGuardError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FloeGuardError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown before an LLM call that would cross the configured spend ceiling.\n *\n * The guard throws this *instead of* letting the next call run, so a runaway loop\n * stops here rather than burning more money.\n */\nexport class BudgetExceeded extends FloeGuardError {\n readonly spentUsd: number;\n readonly limitUsd: number;\n\n constructor(spentUsd: number, limitUsd: number, message?: string) {\n // Subclasses (the token twin) pass their own message through so they don't\n // have to reassign `this.message` after super().\n super(\n message ??\n `BUDGET EXCEEDED — call blocked (spent $${spentUsd.toFixed(6)} of $${limitUsd.toFixed(6)} ceiling)`,\n );\n this.name = \"BudgetExceeded\";\n this.spentUsd = spentUsd;\n this.limitUsd = limitUsd;\n }\n}\n\n/**\n * Thrown before a call that would cross a token ceiling (aggregate or step).\n *\n * The token twin of {@link BudgetExceeded} — it extends it so the same retry\n * logic that treats a USD block as terminal (`!(error instanceof\n * BudgetExceeded)`) treats a token block as terminal too, with no extra wiring.\n * `spentUsd` / `limitUsd` are inherited but not meaningful here; the token\n * fields are the payload.\n *\n * `scope` is `\"aggregate\"` (the guard-wide `tokenLimit`) or `\"step\"` (the\n * innermost active {@link BudgetGuard.step} cap).\n */\nexport class TokenBudgetExceeded extends BudgetExceeded {\n readonly spentTokens: number;\n readonly limitTokens: number;\n readonly scope: \"aggregate\" | \"step\";\n\n constructor(spentTokens: number, limitTokens: number, scope: \"aggregate\" | \"step\") {\n // Pass the token-shaped message through super (BudgetExceeded's default is\n // dollar-shaped); 0/0 for the inherited spentUsd/limitUsd — a token block\n // spent no tracked USD.\n super(\n 0,\n 0,\n `TOKEN BUDGET EXCEEDED — call blocked (${scope}: ${spentTokens} of ` +\n `${limitTokens} token ceiling)`,\n );\n this.name = \"TokenBudgetExceeded\";\n this.spentTokens = spentTokens;\n this.limitTokens = limitTokens;\n this.scope = scope;\n }\n}\n\n/**\n * Thrown when a model cannot be priced and the guard is fail-closed.\n *\n * We refuse rather than silently accrue $0 — \"we cannot cap what we cannot price\".\n * Pass a manual price (`priceOverrides` or `record(..., { price })`) to make the\n * model enforceable.\n */\nexport class UnpriceableModelError extends FloeGuardError {\n readonly model: string;\n\n constructor(model: string) {\n super(\n `Cannot price model '${model}': not in the bundled cost map and no ` +\n `manual price was given. The guard cannot enforce a budget on spend ` +\n `it cannot measure. Pass a price override to enable enforcement.`,\n );\n this.name = \"UnpriceableModelError\";\n this.model = model;\n }\n}\n\n/**\n * Thrown when a voice leg (STT/TTS/telephony) cannot be priced and the guard is\n * fail-closed.\n *\n * The voice twin of {@link UnpriceableModelError}: we refuse rather than silently\n * accrue $0 — \"we cannot cap what we cannot price\". It fires when an adapter is\n * asked to meter a leg for a vendor that is absent from the bundled voice cost map\n * (or whose entry has the wrong unit/mode for the leg) and no per-unit override was\n * given. Pass a per-unit rate (`stt_usd_per_second` / `tts_usd_per_1k_chars` /\n * `telephony_usd_per_minute`) to make the leg enforceable.\n *\n * Mirrors `UnpriceableVoiceError` in `src/floe_guard/errors.py`.\n */\nexport class UnpriceableVoiceError extends FloeGuardError {\n readonly vendor: string | null;\n readonly mode: string;\n\n constructor(vendor: string | null, mode: string) {\n // Match Python's `{vendor!r}`: a string is quoted, None renders as `None`.\n const shown = vendor === null ? \"None\" : `'${vendor}'`;\n super(\n `Cannot price ${mode} vendor ${shown}: not in the bundled voice cost ` +\n `map (or its entry has the wrong unit for a ${mode} leg) and no per-unit ` +\n `override was given. The guard cannot enforce a budget on spend it ` +\n `cannot measure. Pass a per-unit rate to enable enforcement.`,\n );\n this.name = \"UnpriceableVoiceError\";\n this.vendor = vendor;\n this.mode = mode;\n }\n}\n\n/**\n * Thrown when an **opt-in** ledger sync to Reconcile Mode fails.\n *\n * Covers a missing API key, a non-https/malformed base URL, a non-2xx response\n * (401 bad/missing key, 403 agent closed/suspended), a network/timeout failure, or\n * a malformed response. Sync is off by default and only runs when the caller\n * explicitly opts in ({@link BudgetGuard.enableSync} + {@link BudgetGuard.sync}) —\n * this error never fires for a guard that hasn't opted in, because such a guard\n * never sends.\n *\n * Mirrors `LedgerSyncError` in `src/floe_guard/errors.py`.\n */\nexport class LedgerSyncError extends FloeGuardError {\n constructor(message: string) {\n super(message);\n this.name = \"LedgerSyncError\";\n }\n}\n\n/**\n * Thrown before a call whose projected duration would blow the SLA.\n *\n * The latency twin of {@link BudgetExceeded}: `LatencyBudget.check()` throws this\n * *instead of* letting the next tool/model call start, so the chain sheds work or\n * falls back to a faster path rather than violating the end-user SLA. Cooperative —\n * killing an already-running stalled call is the framework's job (AbortSignal),\n * not the guard's.\n *\n * Mirrors `DeadlineExceeded` in `src/floe_guard/errors.py` — message format is\n * kept byte-for-byte identical so both adapters read the same.\n */\n/** Shared millisecond rounding for cross-language message parity: `toFixed(0)`\n * rounds half-up while Python's `:.0f` rounds half-to-even, so tie values\n * would break the byte-for-byte contract. Both packages use floor(x + 0.5)\n * (see `_round_half_up` in `src/floe_guard/errors.py`). */\nfunction roundHalfUp(ms: number): number {\n return Math.floor(ms + 0.5);\n}\n\nexport class DeadlineExceeded extends FloeGuardError {\n readonly elapsedMs: number;\n readonly slaMs: number;\n\n constructor(elapsedMs: number, slaMs: number) {\n super(\n `DEADLINE EXCEEDED — call blocked (elapsed ${roundHalfUp(elapsedMs)}ms of ${roundHalfUp(slaMs)}ms SLA)`,\n );\n this.name = \"DeadlineExceeded\";\n this.elapsedMs = elapsedMs;\n this.slaMs = slaMs;\n }\n}\n","/**\n * Pre-call admission gates for voice orchestrators.\n *\n * These decide **at the call boundary** whether to *admit* or *reject* an incoming\n * call, from the guard's remaining budget. They return the exact JSON shape each\n * provider's inbound webhook expects, so a free/local user can reject a call on\n * budget exhaustion with the **same contract** the hosted gateway serves — the paid\n * upgrade is a URL swap, not a rewrite.\n *\n * Scope — strictly pre-call. A gate answers one question: *given the budget left,\n * do we let this call start?* It does **not** intervene mid-call. Once a call is\n * admitted it runs to completion; nothing here cuts a call off partway.\n *\n * Budget, not balance: admission reads the guard's local *remaining budget*, a\n * ceiling signal — not an account balance. US-only telephony, v1.\n *\n * A faithful port of `src/floe_guard/gates.py`.\n */\n\nimport type { BudgetGuard } from \"./guard.js\";\n\n/**\n * True when there isn't budget left to admit one more call.\n *\n * A **non-binding preflight read**: it checks the guard's `remainingUsd` but does\n * *not* reserve anything, so under concurrent inbound calls it can admit more than\n * the budget strictly covers (two calls may see the same headroom and both pass).\n * It is coarse admission control — the binding, atomic hard-stop is the in-call\n * guard (`check` / `reserve` while the call runs). This mirrors the hosted pre-dial\n * gate, which is likewise check-only.\n *\n * With the default `estimatedCallUsd = 0` a call is rejected only once the budget\n * is fully spent (`remainingUsd` at or below zero). Pass an estimate (e.g.\n * `$/min × expected minutes`) to reject earlier, when the remaining budget can't\n * cover it; an estimate that *exactly* equals the remaining budget still admits\n * (inclusive ceiling, matching `BudgetGuard.reserve`). Budget signal, not a balance.\n *\n * @throws RangeError when `estimatedCallUsd` is negative or non-finite — a bad\n * estimate must not silently admit an exhausted guard (NaN/negative comparisons\n * are always false, the same trap `BudgetGuard` rejects for `limitUsd`).\n */\nexport function budgetExhausted(\n guard: BudgetGuard,\n options: { estimatedCallUsd?: number } = {},\n): boolean {\n // Default ONLY undefined — a `null` estimate is malformed input and must reach\n // validation (below) rather than being silently coerced to 0 (which would admit\n // the call with no intended headroom). Mirrors Python raising on a None estimate.\n const estimatedCallUsd = options.estimatedCallUsd === undefined ? 0 : options.estimatedCallUsd;\n if (!Number.isFinite(estimatedCallUsd) || estimatedCallUsd < 0) {\n throw new RangeError(\n `estimatedCallUsd must be a finite, non-negative number, got ${estimatedCallUsd}`,\n );\n }\n const remainingUsd = guard.remainingUsd;\n return remainingUsd <= 0 || remainingUsd < estimatedCallUsd;\n}\n\n/**\n * Generic pre-call admission decision: `true` = admit, `false` = reject.\n *\n * The provider-agnostic gate for Pipecat, custom telephony, or any inbound hook\n * without a first-class helper below. Wire the `false` case into your provider's\n * reject path.\n *\n * TODO(bland): Bland's *Send Call* metadata field name is an OPEN VERIFICATION\n * ITEM (pending confirmation) — this package does not invent it. Use `preCall` to\n * get the admit/reject decision and map `false` onto Bland's Pathway Webhook node\n * once the field name is confirmed.\n */\nexport function preCall(guard: BudgetGuard, options: { estimatedCallUsd?: number } = {}): boolean {\n return !budgetExhausted(guard, options);\n}\n\n/**\n * Response for Retell's inbound-call webhook — reject or admit the call.\n *\n * On budget exhaustion returns `{ call_inbound: { reject: true } }`; otherwise\n * `{ call_inbound: {...} }` carrying any `admit` overrides you pass\n * (`dynamic_variables`, `metadata`, `override_agent_id`, …).\n *\n * Retell contract (verified against docs.retellai.com/features/inbound-call-webhook):\n * **only the boolean `true` rejects** — any other value is ignored. The webhook\n * fires for inbound **phone and SMS** calls (not dial-to-sip); its behaviour for\n * web calls is not documented, so treat this as phone/SMS-only. 10s timeout, up to\n * 3 retries.\n */\nexport function retell(\n guard: BudgetGuard,\n options: { estimatedCallUsd?: number; admit?: Record<string, unknown> } = {},\n): { call_inbound: Record<string, unknown> } {\n if (budgetExhausted(guard, { estimatedCallUsd: options.estimatedCallUsd })) {\n return { call_inbound: { reject: true } };\n }\n // The gate's budget decision — not the caller's overrides — controls admission.\n // Strip `reject` from admit overrides so an errant `admit: { reject: true }` on\n // an available-budget call can't flip the response into Retell's reject shape.\n const safeAdmit = { ...(options.admit ?? {}) };\n delete safeAdmit.reject;\n return { call_inbound: safeAdmit };\n}\n\n/**\n * Response for Vapi's `assistant-request` webhook — reject or admit the call.\n *\n * On budget exhaustion returns `{ error: errorMessage }` (Vapi speaks it, then ends\n * the call). Otherwise admits with `{ assistantId }` if given (`assistantId` takes\n * precedence), else `{ assistant }`.\n *\n * Vapi has **no** `reject: true` boolean — rejection *is* returning an error, and\n * admission *is* returning an assistant. Respond within **~7.5 s** or the call may\n * fail (verified against docs.vapi.ai/server-url/spam-call-rejection).\n *\n * @throws RangeError when admitted (budget available) but neither `assistant` nor\n * `assistantId` was provided — there'd be nothing to hand Vapi.\n */\nexport function vapi(\n guard: BudgetGuard,\n options: {\n assistant?: Record<string, unknown>;\n assistantId?: string;\n errorMessage?: string;\n estimatedCallUsd?: number;\n } = {},\n): Record<string, unknown> {\n const {\n assistant,\n assistantId,\n errorMessage = \"Sorry, this agent is out of budget right now.\",\n estimatedCallUsd,\n } = options;\n if (budgetExhausted(guard, { estimatedCallUsd })) {\n return { error: errorMessage };\n }\n if (assistantId !== undefined && assistantId !== null) {\n return { assistantId };\n }\n if (assistant !== undefined && assistant !== null) {\n return { assistant };\n }\n throw new RangeError(\n \"vapi() admitted the call but has nothing to return: pass assistant or \" +\n \"assistantId for the admit path.\",\n );\n}\n","{\n \"chatgpt-4o-latest\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"claude-3-7-sonnet-20250219\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-3-haiku-20240307\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.00000125,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-3-opus-20240229\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-4-opus-20250514\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-4-sonnet-20250514\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-fable-5\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-haiku-4-5\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-haiku-4-5-20251001\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-mythos-5\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-mythos-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-1\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-1-20250805\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-20250514\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-5\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-5-20251101\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-6\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-6-20260205\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-7\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-7-20260416\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-8\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-5\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-20250514\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-5\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-5-20250929\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-6\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-5\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo-0125\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo-0613\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo-1106\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4-0613\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4.1-2025-04-14\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4.1-mini-2025-04-14\": {\n \"input_cost_per_token\": 8e-7,\n \"output_cost_per_token\": 0.0000032,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4.1-nano-2025-04-14\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 8e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4o-2024-08-06\": {\n \"input_cost_per_token\": 0.00000375,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4o-2024-11-20\": {\n \"input_cost_per_token\": 0.00000375,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4o-mini-2024-07-18\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:o4-mini-2025-04-16\": {\n \"input_cost_per_token\": 0.000004,\n \"output_cost_per_token\": 0.000016,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash-001\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash-lite\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash-lite-001\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-computer-use-preview-10-2025\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-lite\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-lite-preview-06-17\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-lite-preview-09-2025\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-native-audio-latest\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-native-audio-preview-09-2025\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-native-audio-preview-12-2025\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-preview-09-2025\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-pro\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-pro-preview-tts\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3-flash-preview\": {\n \"input_cost_per_token\": 5e-7,\n \"output_cost_per_token\": 0.000003,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3-pro-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-flash-lite\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-flash-lite-preview\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-flash-live-preview\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.0000045,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-pro-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-pro-preview-customtools\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.5-flash\": {\n \"input_cost_per_token\": 0.0000015,\n \"output_cost_per_token\": 0.000009,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.5-flash-lite\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.6-flash\": {\n \"input_cost_per_token\": 0.0000015,\n \"output_cost_per_token\": 0.0000075,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.7-flash\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.00000375,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-embedding-001\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"embedding\"\n },\n \"gemini-embedding-2\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"embedding\"\n },\n \"gemini-embedding-2-preview\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"embedding\"\n },\n \"gemini-exp-1206\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-flash-latest\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-flash-lite-latest\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-gemma-2-27b-it\": {\n \"input_cost_per_token\": 3.5e-7,\n \"output_cost_per_token\": 0.00000105,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-gemma-2-9b-it\": {\n \"input_cost_per_token\": 3.5e-7,\n \"output_cost_per_token\": 0.00000105,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-omni-flash-preview\": {\n \"input_cost_per_token\": 0.0000015,\n \"output_cost_per_token\": 0.000009,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-pro-latest\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-1.5-preview\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-1.6-preview\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000005,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-2-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-2-streaming-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo\": {\n \"input_cost_per_token\": 5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo-0125\": {\n \"input_cost_per_token\": 5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo-1106\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000002,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo-16k\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000004,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-0125-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-0314\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-0613\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-1106-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-turbo\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-turbo-2024-04-09\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-turbo-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-2025-04-14\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-mini\": {\n \"input_cost_per_token\": 4e-7,\n \"output_cost_per_token\": 0.0000016,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-mini-2025-04-14\": {\n \"input_cost_per_token\": 4e-7,\n \"output_cost_per_token\": 0.0000016,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-nano\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-nano-2025-04-14\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-2024-05-13\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-2024-08-06\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-2024-11-20\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-audio-preview\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-audio-preview-2024-12-17\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-audio-preview-2025-06-03\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-2024-07-18\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-audio-preview\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-audio-preview-2024-12-17\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-search-preview\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-search-preview-2025-03-11\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-search-preview\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-search-preview-2025-03-11\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-2025-08-07\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-chat\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-chat-latest\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-mini\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.000002,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-mini-2025-08-07\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.000002,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-nano\": {\n \"input_cost_per_token\": 5e-8,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-nano-2025-08-07\": {\n \"input_cost_per_token\": 5e-8,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-search-api\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-search-api-2025-10-14\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.1\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.1-2025-11-13\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.1-chat-latest\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.2\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.2-2025-12-11\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.2-chat-latest\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.3-chat-latest\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-2026-03-05\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-mini\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.0000045,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-mini-2026-03-17\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.0000045,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-nano\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0.00000125,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-nano-2026-03-17\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0.00000125,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.5\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.5-2026-04-23\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6-luna\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0.0000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6-sol\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6-terra\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-1.5\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-2025-08-28\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-mini\": {\n \"input_cost_per_token\": 6e-7,\n \"output_cost_per_token\": 0.0000024,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-mini-2025-10-06\": {\n \"input_cost_per_token\": 6e-7,\n \"output_cost_per_token\": 0.0000024,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-mini-2025-12-15\": {\n \"input_cost_per_token\": 6e-7,\n \"output_cost_per_token\": 0.0000024,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"llama-3.1-8b-instant\": {\n \"input_cost_per_token\": 5e-8,\n \"output_cost_per_token\": 8e-8,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"llama-3.3-70b-versatile\": {\n \"input_cost_per_token\": 5.9e-7,\n \"output_cost_per_token\": 7.9e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"meta-llama/llama-4-scout-17b-16e-instruct\": {\n \"input_cost_per_token\": 1.1e-7,\n \"output_cost_per_token\": 3.4e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"o1\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o1-2024-12-17\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3-2025-04-16\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3-mini\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3-mini-2025-01-31\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o4-mini\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o4-mini-2025-04-16\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"openai/gpt-oss-120b\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"openai/gpt-oss-20b\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"openai/gpt-oss-safeguard-20b\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"qwen/qwen3-32b\": {\n \"input_cost_per_token\": 2.9e-7,\n \"output_cost_per_token\": 5.9e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"text-embedding-3-large\": {\n \"input_cost_per_token\": 1.3e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"text-embedding-3-small\": {\n \"input_cost_per_token\": 2e-8,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"text-embedding-ada-002\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"text-embedding-ada-002-v2\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"__voice__\": {\n \"deepgram-nova-3\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0001283333,\n \"provider\": \"deepgram\"\n },\n \"deepgram-nova-3-multilingual\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0001533333,\n \"provider\": \"deepgram\"\n },\n \"deepgram-nova-3-base\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0002416667,\n \"provider\": \"deepgram\"\n },\n \"assemblyai-universal-streaming\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0000416667,\n \"provider\": \"assemblyai\"\n },\n \"elevenlabs-multilingual-v2\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.1,\n \"provider\": \"elevenlabs\"\n },\n \"elevenlabs-flash-v2.5\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.05,\n \"provider\": \"elevenlabs\"\n },\n \"elevenlabs-turbo-v2.5\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.05,\n \"provider\": \"elevenlabs\"\n },\n \"cartesia-sonic\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.03,\n \"provider\": \"cartesia\"\n },\n \"cartesia-line\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.06,\n \"provider\": \"cartesia\"\n },\n \"rime-mist-v2\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.03,\n \"provider\": \"rime\"\n },\n \"twilio-us-inbound-local\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.0085,\n \"provider\": \"twilio\"\n },\n \"twilio-us-outbound-local\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.014,\n \"provider\": \"twilio\"\n },\n \"twilio-us-sip-inbound\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.004,\n \"provider\": \"twilio\"\n }\n }\n}\n","/**\n * Offline pricing for voice legs (STT / TTS / telephony) from the vendored map.\n *\n * The voice twin of `pricing.ts`. The token cost map is per-token; a voice\n * pipeline's bill is per-second (STT), per-1k-chars (TTS), and per-minute\n * (telephony) instead, so the voice rates live under the reserved `\"__voice__\"`\n * key of `cost_map.json` with their own schema:\n *\n * \"deepgram-nova-3\": {\n * \"mode\": \"stt\", // discriminator: \"stt\" | \"tts\" | \"telephony\"\n * \"unit\": \"usd_per_second\", // explicit unit — a mismatch fails closed\n * \"rate\": 0.0001283333, // USD in that unit\n * \"provider\": \"deepgram\"\n * }\n *\n * Same fail-closed contract as token pricing: a vendor absent from the map (or an\n * entry whose `unit`/`mode` does not match the leg it is asked to price) is\n * unpriceable — {@link lookupVoiceRate} returns `null` and the adapter throws\n * {@link UnpriceableVoiceError} rather than silently metering the leg at $0. Pass a\n * per-unit override to enforce a leg the map cannot price.\n *\n * No network. The rates are a **drift-prone snapshot** of each vendor's public\n * list price — refresh them (`scripts/update-cost-map.mjs`) like the token map, or\n * estimates drift as vendors change prices. Telephony is **US-only in v1**.\n *\n * This is a faithful port of `src/floe_guard/voice_pricing.py`.\n */\n\nimport costMapJson from \"./cost_map.json\";\nimport { UnpriceableVoiceError } from \"./errors.js\";\n\nexport type VoiceMode = \"stt\" | \"tts\" | \"telephony\";\n\ninterface VoiceMapEntry {\n mode?: unknown;\n unit?: unknown;\n rate?: unknown;\n provider?: unknown;\n}\n\n/** The vendored voice rates — the reserved `\"__voice__\"` section of the cost map. */\nconst VOICE_MAP = ((costMapJson as Record<string, unknown>)[\"__voice__\"] ?? {}) as Record<\n string,\n VoiceMapEntry\n>;\n\n/**\n * The one unit each leg is billed in. An entry whose `unit` disagrees with its\n * leg is a schema mismatch and fails closed — a Deepgram $/min figure stored\n * without the ÷60 conversion would over-bill 60x if it were silently accepted.\n */\nexport const unitForMode: Record<VoiceMode, string> = {\n stt: \"usd_per_second\",\n tts: \"usd_per_1k_chars\",\n telephony: \"usd_per_minute\",\n};\n\n/** A resolved per-unit voice rate plus where it came from. */\nexport interface VoiceRate {\n mode: string;\n unit: string;\n rate: number;\n source: \"override\" | \"cost_map\";\n}\n\nfunction finiteNonNegative(value: unknown): value is number {\n // typeof excludes booleans (Python's _finite_non_negative excludes bool too).\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0;\n}\n\n/**\n * Resolve a voice vendor to its per-unit rate, or `null` if unpriceable.\n *\n * The pure resolver (the voice twin of {@link resolvePrice}): it never throws.\n * Fail-closed on every mismatch — a missing vendor, an entry whose `mode` is not\n * `mode`, an entry whose `unit` is not the canonical unit for `mode`, or a\n * non-finite/negative rate — so a schema slip can never surface as a silent,\n * valid-looking price.\n */\nexport function lookupVoiceRate(model: string | null | undefined, mode: VoiceMode): number | null {\n if (model === null || model === undefined) return null;\n const entry = Object.prototype.hasOwnProperty.call(VOICE_MAP, model)\n ? VOICE_MAP[model]\n : undefined;\n if (!entry) return null;\n if (entry.mode !== mode) return null;\n if (entry.unit !== unitForMode[mode]) return null;\n const rate = entry.rate;\n if (!finiteNonNegative(rate)) return null;\n return rate;\n}\n\n/**\n * Resolve a leg's per-unit rate, fail-closed. An `override` wins over the map.\n *\n * Throws {@link UnpriceableVoiceError} when neither an override nor the bundled\n * map can price the leg — the guard refuses to meter spend it cannot measure.\n */\nexport function resolveVoiceRate(\n model: string | null | undefined,\n mode: VoiceMode,\n override?: number | null,\n): VoiceRate {\n if (override !== undefined && override !== null) {\n if (!finiteNonNegative(override)) {\n throw new RangeError(\n `voice ${mode} override must be a finite, non-negative number, got ${override}`,\n );\n }\n return { mode, unit: unitForMode[mode], rate: override, source: \"override\" };\n }\n const rate = lookupVoiceRate(model, mode);\n if (rate === null) throw new UnpriceableVoiceError(model ?? null, mode);\n return { mode, unit: unitForMode[mode], rate, source: \"cost_map\" };\n}\n\n/**\n * USD for one leg. `quantity` is seconds (stt), characters (tts), or minutes\n * (telephony); negative quantities clamp to zero.\n */\nexport function voiceLegCost(mode: VoiceMode, quantity: number, rate: number): number {\n // Reject non-finite quantities: Math.max(0, NaN) is NaN, so a NaN/Infinity\n // quantity would return a non-finite USD amount that then poisons the guard's\n // running total (NaN disables every ceiling comparison). Negatives still clamp.\n if (!Number.isFinite(quantity)) {\n throw new RangeError(`voice ${mode} quantity must be a finite number, got ${quantity}`);\n }\n const q = Math.max(0, quantity);\n if (mode === \"stt\") return q * rate; // seconds * $/second\n if (mode === \"tts\") return (q / 1000) * rate; // chars / 1000 * $/1k-chars\n if (mode === \"telephony\") return q * rate; // minutes * $/minute\n throw new RangeError(`unknown voice mode ${mode}`);\n}\n\n/**\n * USD for one voice leg, or `null` when the leg is unconfigured (skip it).\n *\n * The single entry point the adapters use. A leg with neither a vendor (`model`)\n * nor an `override` is unconfigured — return `null` so the token-only contract is\n * preserved and nothing is metered. A leg that *is* configured but cannot be\n * priced throws {@link UnpriceableVoiceError} (via {@link resolveVoiceRate}) rather\n * than accruing a silent $0.\n */\nexport function priceVoiceLeg(\n mode: VoiceMode,\n quantity: number,\n options: { model?: string | null; override?: number | null } = {},\n): number | null {\n const model = options.model ?? null;\n const override = options.override ?? null;\n if (model === null && override === null) return null;\n const resolved = resolveVoiceRate(model, mode, override);\n return voiceLegCost(mode, quantity, resolved.rate);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAQO,IAAM,iBAAN,cAA6B,eAAe;AAAA,EACxC;AAAA,EACA;AAAA,EAET,YAAY,UAAkB,UAAkB,SAAkB;AAGhE;AAAA,MACE,WACE,+CAA0C,SAAS,QAAQ,CAAC,CAAC,QAAQ,SAAS,QAAQ,CAAC,CAAC;AAAA,IAC5F;AACA,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AACF;AAsEO,IAAM,wBAAN,cAAoC,eAAe;AAAA,EAC/C;AAAA,EACA;AAAA,EAET,YAAY,QAAuB,MAAc;AAE/C,UAAM,QAAQ,WAAW,OAAO,SAAS,IAAI,MAAM;AACnD;AAAA,MACE,gBAAgB,IAAI,WAAW,KAAK,8EACY,IAAI;AAAA,IAGtD;AACA,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;;;ACtFO,SAAS,gBACd,OACA,UAAyC,CAAC,GACjC;AAIT,QAAM,mBAAmB,QAAQ,qBAAqB,SAAY,IAAI,QAAQ;AAC9E,MAAI,CAAC,OAAO,SAAS,gBAAgB,KAAK,mBAAmB,GAAG;AAC9D,UAAM,IAAI;AAAA,MACR,+DAA+D,gBAAgB;AA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QAAI,SAAS,UAAa,KAAK,MAAM;AACnC,WAAK,MAAM,QAAQ,KAAK,MAAM;AAC9B,WAAK,OAAO;AACZ,WAAK,MAAM,OAAO,EAAE;AAAA,IACtB;AACA,SAAK,mBAAmB;AAAA,EAC1B;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/retell.ts","../../src/errors.ts","../../src/gates.ts","../../src/cost_map.json","../../src/voice-pricing.ts"],"sourcesContent":["/**\n * Retell custom-LLM WebSocket adapter (optional peer: the `ws` server your custom\n * LLM already runs — this adapter never opens or hard-depends on it).\n *\n * Retell's custom LLM runs over a WebSocket (docs.retellai.com/api-references/\n * llm-websocket). Retell sends interaction events to your server; the billable one\n * is **`response_required`** (an auto-incrementing `response_id` plus the running\n * `transcript`), and its twin **`reminder_required`**. Your server streams back\n * **`response`** events — many partials per turn — ending with `content_complete:\n * true`. A NEW `response_required` with a higher `response_id` means the caller\n * barged in: it **interrupts** the turn in flight, which never reaches\n * `content_complete`.\n *\n * Like the LiveKit adapter, a Retell call has no single call site to wrap: turns\n * fire for the life of the socket. The two enforcement points are the arrival of a\n * `response_required` (before the LLM call, so a turn is admitted or blocked before\n * its TTS/telephony spend piles on) and the turn's real token usage (after\n * `content_complete`). {@link RetellBudgetGuard} holds the reservation across both,\n * keyed by `response_id`, and releases it when a newer turn interrupts.\n *\n * import { BudgetGuard } from \"floe-guard\";\n * import { RetellBudgetGuard } from \"floe-guard/adapters/retell\";\n *\n * const guard = new BudgetGuard(1.0, {\n * priceOverrides: {\n * \"gpt-4o-mini\": { inputCostPerToken: 0.15e-6, outputCostPerToken: 0.6e-6 },\n * },\n * });\n * const budget = new RetellBudgetGuard(guard, {\n * model: \"gpt-4o-mini\",\n * sttModel: \"deepgram-nova-3\",\n * ttsModel: \"elevenlabs-flash-v2.5\",\n * telephony: \"twilio-us-inbound-local\",\n * });\n *\n * // In your custom-LLM WS message handler:\n * ws.on(\"message\", async (raw) => {\n * const event = JSON.parse(raw);\n * if (event.interaction_type === \"response_required\" ||\n * event.interaction_type === \"reminder_required\") {\n * const turn = budget.beginTurn(event); // reserve before the LLM call\n * if (!turn.admitted) { // budget exhausted\n * ws.send(JSON.stringify(\n * budget.response(event.response_id, \"I'm out of budget — wrapping up.\",\n * { complete: true, endCall: true })));\n * return;\n * }\n * const { text, usage } = await callYourLlm(event.transcript); // your LLM\n * ws.send(JSON.stringify(budget.response(event.response_id, text, { complete: true })));\n * budget.settleTurn(event.response_id, usage); // settle real token usage\n * }\n * });\n *\n * ## Why a WebSocket adapter, not a request wrapper\n *\n * The custom LLM sees only the **LLM leg** (the tokens behind each `response`). STT,\n * TTS and telephony are billed by Retell/the carrier and never cross this socket, so\n * they are metered **explicitly** — call {@link RetellBudgetGuard.meterStt} /\n * {@link RetellBudgetGuard.meterTts} / {@link RetellBudgetGuard.meterTelephony} from\n * wherever those durations are known (webhook, call-ended event). Each is priced\n * from the bundled voice cost map when you name the vendor, or a per-unit override\n * which wins over the map; a leg with neither is left un-metered (the token-only\n * contract), and a named vendor the map cannot price fails closed\n * ({@link UnpriceableVoiceError}).\n *\n * Scope is strictly **pre-turn / pre-call admission plus per-turn settlement**.\n * There is no mid-call intervention: an admitted turn runs to `content_complete`;\n * nothing here cuts a turn off partway. The only release is the interrupt Retell\n * itself signals (a newer `response_id`) or an explicit {@link RetellBudgetGuard.close}\n * on call teardown.\n */\n\nimport { BudgetExceeded } from \"../errors.js\";\nimport * as gates from \"../gates.js\";\nimport type { BudgetGuard, ReservationHandle } from \"../guard.js\";\nimport { priceVoiceLeg } from \"../voice-pricing.js\";\n\n/** One entry of a Retell `transcript` (loosely typed — we never read into it). */\nexport interface RetellUtterance {\n readonly role: \"agent\" | \"user\";\n readonly content: string;\n}\n\n/**\n * The Retell interaction events that require a turn. `response_required` is a real\n * user utterance; `reminder_required` fires after silence — both carry an\n * auto-incrementing `response_id` and expect a `response` stream in reply. Typed\n * structurally so a parsed WS message satisfies it with no Retell SDK dependency.\n */\nexport interface RetellResponseRequiredEvent {\n readonly interaction_type: \"response_required\" | \"reminder_required\";\n /** Auto-incrementing turn id; a higher value than the open turn means an interrupt. */\n readonly response_id: number;\n readonly transcript?: readonly RetellUtterance[];\n}\n\n/**\n * A `response` event to stream back to Retell. Emit several partials per turn\n * (`content_complete: false`), then a final one with `content_complete: true`.\n * Build them with {@link RetellBudgetGuard.response}.\n */\nexport interface RetellResponseEvent {\n readonly response_type: \"response\";\n readonly response_id: number;\n readonly content: string;\n readonly content_complete: boolean;\n readonly end_call?: boolean;\n}\n\n/** Real token usage for a settled turn — the LLM leg the socket sees. */\nexport interface RetellTokenUsage {\n readonly promptTokens: number;\n readonly completionTokens: number;\n}\n\n/**\n * The decision {@link RetellBudgetGuard.beginTurn} returns. `admitted: true` means\n * the turn's reservation is held — run the LLM and settle it. `admitted: false`\n * means the budget is spent: send a wrap-up `response` (with `content_complete`) and\n * do not call the LLM; `error` carries the {@link BudgetExceeded} for logging.\n */\nexport type RetellTurnDecision =\n | { readonly admitted: true; readonly responseId: number }\n | { readonly admitted: false; readonly responseId: number; readonly error: BudgetExceeded };\n\nexport interface RetellBudgetGuardOptions {\n /**\n * Model id to settle LLM cost against (Retell's usage payload names no model we\n * rely on). Must be priceable via the bundled cost map or the guard's\n * `priceOverrides`.\n */\n model: string;\n /** Voice-map vendor key for the STT leg (e.g. `\"deepgram-nova-3\"`). */\n sttModel?: string;\n /** Voice-map vendor key for the TTS leg (e.g. `\"elevenlabs-flash-v2.5\"`). */\n ttsModel?: string;\n /** Voice-map vendor key for the telephony leg (e.g. `\"twilio-us-inbound-local\"`). */\n telephony?: string;\n /** Per-second STT override — wins over `sttModel`. Omit both to leave STT un-metered. */\n sttUsdPerSecond?: number;\n /** Per-1k-chars TTS override — wins over `ttsModel`. Omit both to leave TTS un-metered. */\n ttsUsdPer1kChars?: number;\n /** Per-minute telephony override — wins over `telephony`. */\n telephonyUsdPerMinute?: number;\n}\n\n/**\n * One turn's reservation, keyed by `response_id`. `open` means the USD amount is\n * still held on the {@link BudgetGuard}. A settle or an interrupt closes it.\n */\ninterface TurnSlot {\n readonly responseId: number;\n amount: ReservationHandle;\n open: boolean;\n}\n\n/**\n * Enforce a {@link BudgetGuard} ceiling on a Retell custom-LLM socket, one turn at\n * a time: reserve when a `response_required` arrives, settle on real token usage\n * after `content_complete`, release when a newer `response_id` interrupts.\n */\nexport class RetellBudgetGuard {\n private readonly guard: BudgetGuard;\n private readonly model: string;\n private readonly sttModel?: string;\n private readonly ttsModel?: string;\n private readonly telephony?: string;\n private readonly sttUsdPerSecond?: number;\n private readonly ttsUsdPer1kChars?: number;\n private readonly telephonyUsdPerMinute?: number;\n\n /** Open (and just-settled) turns keyed by `response_id`. */\n private readonly slots = new Map<number, TurnSlot>();\n /** The most recently begun turn — the one a newer `response_required` interrupts. */\n private activeResponseId: number | null = null;\n\n constructor(guard: BudgetGuard, options: RetellBudgetGuardOptions) {\n this.guard = guard;\n this.model = options.model;\n this.sttModel = options.sttModel;\n this.ttsModel = options.ttsModel;\n this.telephony = options.telephony;\n this.sttUsdPerSecond = options.sttUsdPerSecond;\n this.ttsUsdPer1kChars = options.ttsUsdPer1kChars;\n this.telephonyUsdPerMinute = options.telephonyUsdPerMinute;\n }\n\n /**\n * Reserve budget for a `response_required` / `reminder_required` turn before its\n * LLM call runs. Returns an admit/block {@link RetellTurnDecision}.\n *\n * A newer `response_id` arriving while a prior turn is still open is Retell's\n * interrupt signal — this releases that prior turn's hold before reserving the new\n * one (its `content_complete` will never arrive). Reserving here is what blocks a\n * turn before its downstream TTS/telephony spend piles on. Calling twice with the\n * same still-open `response_id` is idempotent (no double hold).\n */\n beginTurn(event: RetellResponseRequiredEvent): RetellTurnDecision {\n const responseId = event.response_id;\n\n // Idempotent: this turn already holds a reservation.\n const existing = this.slots.get(responseId);\n if (existing !== undefined && existing.open) {\n return { admitted: true, responseId };\n }\n\n // A newer turn interrupts the prior open turn — free its hold before opening this\n // one. Its usage never settles (no content_complete); a stray late settle for it\n // finds no open slot and records actual usage against a zero reservation.\n this.releaseActive(responseId);\n\n let handle: ReservationHandle;\n try {\n handle = this.guard.reserve(); // throws BudgetExceeded before the turn runs\n } catch (err) {\n if (err instanceof BudgetExceeded) {\n return { admitted: false, responseId, error: err };\n }\n throw err;\n }\n\n this.slots.set(responseId, { responseId, amount: handle, open: true });\n this.activeResponseId = responseId;\n return { admitted: true, responseId };\n }\n\n /**\n * Settle a turn's real token usage after its `content_complete`. Consumes the\n * reservation opened by {@link beginTurn} for this `response_id`; a turn with no\n * open slot (already interrupted, or a settle for an id never begun) records the\n * usage against a zero reservation instead of stealing another turn's hold.\n */\n settleTurn(responseId: number, usage: RetellTokenUsage): void {\n let reserved: ReservationHandle = 0;\n const slot = this.slots.get(responseId);\n if (slot !== undefined) {\n if (slot.open) {\n reserved = slot.amount;\n slot.open = false;\n }\n this.slots.delete(responseId);\n }\n if (this.activeResponseId === responseId) this.activeResponseId = null;\n this.guard.settle(this.model, usage.promptTokens, usage.completionTokens, { reserved });\n }\n\n /**\n * Pre-call admission for Retell's inbound-call webhook, wrapping {@link gates.retell}.\n * On budget exhaustion returns `{ call_inbound: { reject: true } }`; otherwise\n * `{ call_inbound: {...} }` carrying any `admit` overrides (`dynamic_variables`,\n * `metadata`, `override_agent_id`, …).\n *\n * A coarse, non-binding preflight — the binding hard-stop is the per-turn reserve\n * in {@link beginTurn}. Pass `estimatedCallUsd` (e.g. `$/min × expected minutes`)\n * to reject earlier, when the remaining budget can't cover the call.\n */\n admitCall(\n options: { estimatedCallUsd?: number; admit?: Record<string, unknown> } = {},\n ): { call_inbound: Record<string, unknown> } {\n return gates.retell(this.guard, options);\n }\n\n /**\n * Build a `response` event to stream back to Retell. Send partials with\n * `complete: false`, then a final one with `complete: true`; settle the turn's\n * token usage after that final one. Pass `endCall: true` to hang up (e.g. on a\n * budget wrap-up line). A thin convenience — you may build the shape yourself.\n */\n response(\n responseId: number,\n content: string,\n options: { complete?: boolean; endCall?: boolean } = {},\n ): RetellResponseEvent {\n return {\n response_type: \"response\",\n response_id: responseId,\n content,\n content_complete: options.complete ?? false,\n ...(options.endCall ? { end_call: true } : {}),\n };\n }\n\n /**\n * Accrue STT spend for `seconds` of transcribed audio (per-second). The socket\n * never sees the STT leg, so drive this from wherever the duration is known.\n * Priced from the voice map when `sttModel` is set, or the `sttUsdPerSecond`\n * override; returns `null` (no-op) when the leg is unconfigured, and fails closed\n * on a vendor the map cannot price. Returns the USD accrued, if any.\n */\n meterStt(seconds: number): number | null {\n const cost = priceVoiceLeg(\"stt\", seconds, {\n model: this.sttModel,\n override: this.sttUsdPerSecond,\n });\n if (cost !== null) this.guard.recordTool(\"retell-stt\", cost);\n return cost;\n }\n\n /**\n * Accrue TTS spend for `characters` of synthesized speech (per-1k-chars). Priced\n * from the voice map when `ttsModel` is set, or the `ttsUsdPer1kChars` override;\n * returns `null` when unconfigured, and fails closed on an unpriceable vendor.\n */\n meterTts(characters: number): number | null {\n const cost = priceVoiceLeg(\"tts\", characters, {\n model: this.ttsModel,\n override: this.ttsUsdPer1kChars,\n });\n if (cost !== null) this.guard.recordTool(\"retell-tts\", cost);\n return cost;\n }\n\n /**\n * Accrue telephony spend for `minutes` of call time (per-minute). Per-minute\n * accrual, not live line-cutting: the guard meters the leg, it does not cut the\n * phone line mid-call. Priced from the voice map when `telephony` is set, or the\n * `telephonyUsdPerMinute` override; returns `null` when unconfigured, and fails\n * closed on an unpriceable vendor. Returns the USD accrued, if any.\n */\n meterTelephony(minutes: number): number | null {\n const cost = priceVoiceLeg(\"telephony\", minutes, {\n model: this.telephony,\n override: this.telephonyUsdPerMinute,\n });\n if (cost !== null) this.guard.recordTool(\"retell-telephony\", cost);\n return cost;\n }\n\n /**\n * Release any still-open turn's reservation on call teardown (socket close, call\n * ended). A turn that never reached `content_complete` would otherwise leak its\n * hold and shrink `remainingUsd` permanently.\n */\n close(): void {\n for (const slot of this.slots.values()) {\n if (slot.open) this.guard.release(slot.amount);\n }\n this.slots.clear();\n this.activeResponseId = null;\n }\n\n /** Release the active open turn's hold unless it is `exceptId` (the incoming turn). */\n private releaseActive(exceptId: number): void {\n const id = this.activeResponseId;\n if (id === null || id === exceptId) return;\n const slot = this.slots.get(id);\n if (slot !== undefined && slot.open) {\n this.guard.release(slot.amount);\n slot.open = false;\n this.slots.delete(id);\n }\n this.activeResponseId = null;\n }\n}\n","/**\n * Exceptions for floe-guard.\n *\n * Everything derives from {@link FloeGuardError} (the package-root base) so callers\n * can catch the whole family with a single `catch (e) { if (e instanceof FloeGuardError) ... }`.\n *\n * Mirrors `src/floe_guard/errors.py` in the Python package — message formats are\n * kept byte-for-byte identical so both adapters read the same.\n */\n\n/** Base class for every error raised by floe-guard. */\nexport class FloeGuardError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FloeGuardError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown before an LLM call that would cross the configured spend ceiling.\n *\n * The guard throws this *instead of* letting the next call run, so a runaway loop\n * stops here rather than burning more money.\n */\nexport class BudgetExceeded extends FloeGuardError {\n readonly spentUsd: number;\n readonly limitUsd: number;\n\n constructor(spentUsd: number, limitUsd: number, message?: string) {\n // Subclasses (the token twin) pass their own message through so they don't\n // have to reassign `this.message` after super().\n super(\n message ??\n `BUDGET EXCEEDED — call blocked (spent $${spentUsd.toFixed(6)} of $${limitUsd.toFixed(6)} ceiling)`,\n );\n this.name = \"BudgetExceeded\";\n this.spentUsd = spentUsd;\n this.limitUsd = limitUsd;\n }\n}\n\n/**\n * Thrown before a call that would cross a token ceiling (aggregate or step).\n *\n * The token twin of {@link BudgetExceeded} — it extends it so the same retry\n * logic that treats a USD block as terminal (`!(error instanceof\n * BudgetExceeded)`) treats a token block as terminal too, with no extra wiring.\n * `spentUsd` / `limitUsd` are inherited but not meaningful here; the token\n * fields are the payload.\n *\n * `scope` is `\"aggregate\"` (the guard-wide `tokenLimit`) or `\"step\"` (the\n * innermost active {@link BudgetGuard.step} cap).\n */\nexport class TokenBudgetExceeded extends BudgetExceeded {\n readonly spentTokens: number;\n readonly limitTokens: number;\n readonly scope: \"aggregate\" | \"step\";\n\n constructor(spentTokens: number, limitTokens: number, scope: \"aggregate\" | \"step\") {\n // Pass the token-shaped message through super (BudgetExceeded's default is\n // dollar-shaped); 0/0 for the inherited spentUsd/limitUsd — a token block\n // spent no tracked USD.\n super(\n 0,\n 0,\n `TOKEN BUDGET EXCEEDED — call blocked (${scope}: ${spentTokens} of ` +\n `${limitTokens} token ceiling)`,\n );\n this.name = \"TokenBudgetExceeded\";\n this.spentTokens = spentTokens;\n this.limitTokens = limitTokens;\n this.scope = scope;\n }\n}\n\n/**\n * Thrown when a model cannot be priced and the guard is fail-closed.\n *\n * We refuse rather than silently accrue $0 — \"we cannot cap what we cannot price\".\n * Pass a manual price (`priceOverrides` or `record(..., { price })`) to make the\n * model enforceable.\n */\nexport class UnpriceableModelError extends FloeGuardError {\n readonly model: string;\n\n constructor(model: string) {\n super(\n `Cannot price model '${model}': not in the bundled cost map and no ` +\n `manual price was given. The guard cannot enforce a budget on spend ` +\n `it cannot measure. Pass a price override to enable enforcement.`,\n );\n this.name = \"UnpriceableModelError\";\n this.model = model;\n }\n}\n\n/**\n * Thrown when a voice leg (STT/TTS/telephony) cannot be priced and the guard is\n * fail-closed.\n *\n * The voice twin of {@link UnpriceableModelError}: we refuse rather than silently\n * accrue $0 — \"we cannot cap what we cannot price\". It fires when an adapter is\n * asked to meter a leg for a vendor that is absent from the bundled voice cost map\n * (or whose entry has the wrong unit/mode for the leg) and no per-unit override was\n * given. Pass a per-unit rate (`stt_usd_per_second` / `tts_usd_per_1k_chars` /\n * `telephony_usd_per_minute`) to make the leg enforceable.\n *\n * Mirrors `UnpriceableVoiceError` in `src/floe_guard/errors.py`.\n */\nexport class UnpriceableVoiceError extends FloeGuardError {\n readonly vendor: string | null;\n readonly mode: string;\n\n constructor(vendor: string | null, mode: string) {\n // Match Python's `{vendor!r}`: a string is quoted, None renders as `None`.\n const shown = vendor === null ? \"None\" : `'${vendor}'`;\n super(\n `Cannot price ${mode} vendor ${shown}: not in the bundled voice cost ` +\n `map (or its entry has the wrong unit for a ${mode} leg) and no per-unit ` +\n `override was given. The guard cannot enforce a budget on spend it ` +\n `cannot measure. Pass a per-unit rate to enable enforcement.`,\n );\n this.name = \"UnpriceableVoiceError\";\n this.vendor = vendor;\n this.mode = mode;\n }\n}\n\n/**\n * Thrown when an **opt-in** ledger sync to Reconcile Mode fails.\n *\n * Covers a missing API key, a non-https/malformed base URL, a non-2xx response\n * (401 bad/missing key, 403 agent closed/suspended), a network/timeout failure, or\n * a malformed response. Sync is off by default and only runs when the caller\n * explicitly opts in ({@link BudgetGuard.enableSync} + {@link BudgetGuard.sync}) —\n * this error never fires for a guard that hasn't opted in, because such a guard\n * never sends.\n *\n * Mirrors `LedgerSyncError` in `src/floe_guard/errors.py`.\n */\nexport class LedgerSyncError extends FloeGuardError {\n constructor(message: string) {\n super(message);\n this.name = \"LedgerSyncError\";\n }\n}\n\n/**\n * Thrown before a call whose projected duration would blow the SLA.\n *\n * The latency twin of {@link BudgetExceeded}: `LatencyBudget.check()` throws this\n * *instead of* letting the next tool/model call start, so the chain sheds work or\n * falls back to a faster path rather than violating the end-user SLA. Cooperative —\n * killing an already-running stalled call is the framework's job (AbortSignal),\n * not the guard's.\n *\n * Mirrors `DeadlineExceeded` in `src/floe_guard/errors.py` — message format is\n * kept byte-for-byte identical so both adapters read the same.\n */\n/** Shared millisecond rounding for cross-language message parity: `toFixed(0)`\n * rounds half-up while Python's `:.0f` rounds half-to-even, so tie values\n * would break the byte-for-byte contract. Both packages use floor(x + 0.5)\n * (see `_round_half_up` in `src/floe_guard/errors.py`). */\nfunction roundHalfUp(ms: number): number {\n return Math.floor(ms + 0.5);\n}\n\nexport class DeadlineExceeded extends FloeGuardError {\n readonly elapsedMs: number;\n readonly slaMs: number;\n\n constructor(elapsedMs: number, slaMs: number) {\n super(\n `DEADLINE EXCEEDED — call blocked (elapsed ${roundHalfUp(elapsedMs)}ms of ${roundHalfUp(slaMs)}ms SLA)`,\n );\n this.name = \"DeadlineExceeded\";\n this.elapsedMs = elapsedMs;\n this.slaMs = slaMs;\n }\n}\n","/**\n * Pre-call admission gates for voice orchestrators.\n *\n * These decide **at the call boundary** whether to *admit* or *reject* an incoming\n * call, from the guard's remaining budget. They return the exact JSON shape each\n * provider's inbound webhook expects, so a free/local user can reject a call on\n * budget exhaustion with the **same contract** the hosted gateway serves — the paid\n * upgrade is a URL swap, not a rewrite.\n *\n * Scope — strictly pre-call. A gate answers one question: *given the budget left,\n * do we let this call start?* It does **not** intervene mid-call. Once a call is\n * admitted it runs to completion; nothing here cuts a call off partway.\n *\n * Budget, not balance: admission reads the guard's local *remaining budget*, a\n * ceiling signal — not an account balance. US-only telephony, v1.\n *\n * A faithful port of `src/floe_guard/gates.py`.\n */\n\nimport type { BudgetGuard } from \"./guard.js\";\n\n/**\n * True when there isn't budget left to admit one more call.\n *\n * A **non-binding preflight read**: it checks the guard's `remainingUsd` but does\n * *not* reserve anything, so under concurrent inbound calls it can admit more than\n * the budget strictly covers (two calls may see the same headroom and both pass).\n * It is coarse admission control — the binding, atomic hard-stop is the in-call\n * guard (`check` / `reserve` while the call runs). This mirrors the hosted pre-dial\n * gate, which is likewise check-only.\n *\n * With the default `estimatedCallUsd = 0` a call is rejected only once the budget\n * is fully spent (`remainingUsd` at or below zero). Pass an estimate (e.g.\n * `$/min × expected minutes`) to reject earlier, when the remaining budget can't\n * cover it; an estimate that *exactly* equals the remaining budget still admits\n * (inclusive ceiling, matching `BudgetGuard.reserve`). Budget signal, not a balance.\n *\n * @throws RangeError when `estimatedCallUsd` is negative or non-finite — a bad\n * estimate must not silently admit an exhausted guard (NaN/negative comparisons\n * are always false, the same trap `BudgetGuard` rejects for `limitUsd`).\n */\nexport function budgetExhausted(\n guard: BudgetGuard,\n options: { estimatedCallUsd?: number } = {},\n): boolean {\n // Default ONLY undefined — a `null` estimate is malformed input and must reach\n // validation (below) rather than being silently coerced to 0 (which would admit\n // the call with no intended headroom). Mirrors Python raising on a None estimate.\n const estimatedCallUsd = options.estimatedCallUsd === undefined ? 0 : options.estimatedCallUsd;\n if (!Number.isFinite(estimatedCallUsd) || estimatedCallUsd < 0) {\n throw new RangeError(\n `estimatedCallUsd must be a finite, non-negative number, got ${estimatedCallUsd}`,\n );\n }\n const remainingUsd = guard.remainingUsd;\n return remainingUsd <= 0 || remainingUsd < estimatedCallUsd;\n}\n\n/**\n * Generic pre-call admission decision: `true` = admit, `false` = reject.\n *\n * The provider-agnostic gate for Pipecat, custom telephony, or any inbound hook\n * without a first-class helper below. Wire the `false` case into your provider's\n * reject path.\n *\n * TODO(bland): Bland's *Send Call* metadata field name is an OPEN VERIFICATION\n * ITEM (pending confirmation) — this package does not invent it. Use `preCall` to\n * get the admit/reject decision and map `false` onto Bland's Pathway Webhook node\n * once the field name is confirmed.\n */\nexport function preCall(guard: BudgetGuard, options: { estimatedCallUsd?: number } = {}): boolean {\n return !budgetExhausted(guard, options);\n}\n\n/**\n * Response for Retell's inbound-call webhook — reject or admit the call.\n *\n * On budget exhaustion returns `{ call_inbound: { reject: true } }`; otherwise\n * `{ call_inbound: {...} }` carrying any `admit` overrides you pass\n * (`dynamic_variables`, `metadata`, `override_agent_id`, …).\n *\n * Retell contract (verified against docs.retellai.com/features/inbound-call-webhook):\n * **only the boolean `true` rejects** — any other value is ignored. The webhook\n * fires for inbound **phone and SMS** calls (not dial-to-sip); its behaviour for\n * web calls is not documented, so treat this as phone/SMS-only. 10s timeout, up to\n * 3 retries.\n */\nexport function retell(\n guard: BudgetGuard,\n options: { estimatedCallUsd?: number; admit?: Record<string, unknown> } = {},\n): { call_inbound: Record<string, unknown> } {\n if (budgetExhausted(guard, { estimatedCallUsd: options.estimatedCallUsd })) {\n return { call_inbound: { reject: true } };\n }\n // The gate's budget decision — not the caller's overrides — controls admission.\n // Strip `reject` from admit overrides so an errant `admit: { reject: true }` on\n // an available-budget call can't flip the response into Retell's reject shape.\n const safeAdmit = { ...(options.admit ?? {}) };\n delete safeAdmit.reject;\n return { call_inbound: safeAdmit };\n}\n\n/**\n * Response for Vapi's `assistant-request` webhook — reject or admit the call.\n *\n * On budget exhaustion returns `{ error: errorMessage }` (Vapi speaks it, then ends\n * the call). Otherwise admits with `{ assistantId }` if given (`assistantId` takes\n * precedence), else `{ assistant }`.\n *\n * Vapi has **no** `reject: true` boolean — rejection *is* returning an error, and\n * admission *is* returning an assistant. Respond within **~7.5 s** or the call may\n * fail (verified against docs.vapi.ai/server-url/spam-call-rejection).\n *\n * @throws RangeError when admitted (budget available) but neither `assistant` nor\n * `assistantId` was provided — there'd be nothing to hand Vapi.\n */\nexport function vapi(\n guard: BudgetGuard,\n options: {\n assistant?: Record<string, unknown>;\n assistantId?: string;\n errorMessage?: string;\n estimatedCallUsd?: number;\n } = {},\n): Record<string, unknown> {\n const {\n assistant,\n assistantId,\n errorMessage = \"Sorry, this agent is out of budget right now.\",\n estimatedCallUsd,\n } = options;\n if (budgetExhausted(guard, { estimatedCallUsd })) {\n return { error: errorMessage };\n }\n if (assistantId !== undefined && assistantId !== null) {\n return { assistantId };\n }\n if (assistant !== undefined && assistant !== null) {\n return { assistant };\n }\n throw new RangeError(\n \"vapi() admitted the call but has nothing to return: pass assistant or \" +\n \"assistantId for the admit path.\",\n );\n}\n","{\n \"chatgpt-4o-latest\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"claude-3-7-sonnet-20250219\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-3-haiku-20240307\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.00000125,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-3-opus-20240229\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-4-opus-20250514\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-4-sonnet-20250514\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-fable-5\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-haiku-4-5\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-haiku-4-5-20251001\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-mythos-5\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-mythos-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00005,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-1\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-1-20250805\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-20250514\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.000075,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-5\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-5-20251101\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-6\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-6-20260205\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-7\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-7-20260416\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-4-8\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-opus-5\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000025,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-20250514\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-5\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-5-20250929\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-4-6\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-sonnet-5\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo-0125\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo-0613\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-3.5-turbo-1106\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4-0613\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4.1-2025-04-14\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4.1-mini-2025-04-14\": {\n \"input_cost_per_token\": 8e-7,\n \"output_cost_per_token\": 0.0000032,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4.1-nano-2025-04-14\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 8e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4o-2024-08-06\": {\n \"input_cost_per_token\": 0.00000375,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4o-2024-11-20\": {\n \"input_cost_per_token\": 0.00000375,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:gpt-4o-mini-2024-07-18\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"ft:o4-mini-2025-04-16\": {\n \"input_cost_per_token\": 0.000004,\n \"output_cost_per_token\": 0.000016,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash-001\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash-lite\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.0-flash-lite-001\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-computer-use-preview-10-2025\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-lite\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-lite-preview-06-17\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-lite-preview-09-2025\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-native-audio-latest\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-native-audio-preview-09-2025\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-native-audio-preview-12-2025\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-flash-preview-09-2025\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-pro\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-2.5-pro-preview-tts\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3-flash-preview\": {\n \"input_cost_per_token\": 5e-7,\n \"output_cost_per_token\": 0.000003,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3-pro-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-flash-lite\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-flash-lite-preview\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-flash-live-preview\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.0000045,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-pro-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.1-pro-preview-customtools\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.5-flash\": {\n \"input_cost_per_token\": 0.0000015,\n \"output_cost_per_token\": 0.000009,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.5-flash-lite\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.6-flash\": {\n \"input_cost_per_token\": 0.0000015,\n \"output_cost_per_token\": 0.0000075,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-3.7-flash\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.00000375,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-embedding-001\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"embedding\"\n },\n \"gemini-embedding-2\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"embedding\"\n },\n \"gemini-embedding-2-preview\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"embedding\"\n },\n \"gemini-exp-1206\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-flash-latest\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-flash-lite-latest\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-gemma-2-27b-it\": {\n \"input_cost_per_token\": 3.5e-7,\n \"output_cost_per_token\": 0.00000105,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-gemma-2-9b-it\": {\n \"input_cost_per_token\": 3.5e-7,\n \"output_cost_per_token\": 0.00000105,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-omni-flash-preview\": {\n \"input_cost_per_token\": 0.0000015,\n \"output_cost_per_token\": 0.000009,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-pro-latest\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-1.5-preview\": {\n \"input_cost_per_token\": 3e-7,\n \"output_cost_per_token\": 0.0000025,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-1.6-preview\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000005,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-2-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gemini-robotics-er-2-streaming-preview\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"gemini\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo\": {\n \"input_cost_per_token\": 5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo-0125\": {\n \"input_cost_per_token\": 5e-7,\n \"output_cost_per_token\": 0.0000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo-1106\": {\n \"input_cost_per_token\": 0.000001,\n \"output_cost_per_token\": 0.000002,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-3.5-turbo-16k\": {\n \"input_cost_per_token\": 0.000003,\n \"output_cost_per_token\": 0.000004,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-0125-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-0314\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-0613\": {\n \"input_cost_per_token\": 0.00003,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-1106-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-turbo\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-turbo-2024-04-09\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4-turbo-preview\": {\n \"input_cost_per_token\": 0.00001,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-2025-04-14\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-mini\": {\n \"input_cost_per_token\": 4e-7,\n \"output_cost_per_token\": 0.0000016,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-mini-2025-04-14\": {\n \"input_cost_per_token\": 4e-7,\n \"output_cost_per_token\": 0.0000016,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-nano\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4.1-nano-2025-04-14\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-2024-05-13\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-2024-08-06\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-2024-11-20\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-audio-preview\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-audio-preview-2024-12-17\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-audio-preview-2025-06-03\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-2024-07-18\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-audio-preview\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-audio-preview-2024-12-17\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-search-preview\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-mini-search-preview-2025-03-11\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-search-preview\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-4o-search-preview-2025-03-11\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-2025-08-07\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-chat\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-chat-latest\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-mini\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.000002,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-mini-2025-08-07\": {\n \"input_cost_per_token\": 2.5e-7,\n \"output_cost_per_token\": 0.000002,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-nano\": {\n \"input_cost_per_token\": 5e-8,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-nano-2025-08-07\": {\n \"input_cost_per_token\": 5e-8,\n \"output_cost_per_token\": 4e-7,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-search-api\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5-search-api-2025-10-14\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.1\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.1-2025-11-13\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.1-chat-latest\": {\n \"input_cost_per_token\": 0.00000125,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.2\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.2-2025-12-11\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.2-chat-latest\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.3-chat-latest\": {\n \"input_cost_per_token\": 0.00000175,\n \"output_cost_per_token\": 0.000014,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-2026-03-05\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.000015,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-mini\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.0000045,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-mini-2026-03-17\": {\n \"input_cost_per_token\": 7.5e-7,\n \"output_cost_per_token\": 0.0000045,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-nano\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0.00000125,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.4-nano-2026-03-17\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0.00000125,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.5\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.5-2026-04-23\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6-luna\": {\n \"input_cost_per_token\": 2e-7,\n \"output_cost_per_token\": 0.0000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6-sol\": {\n \"input_cost_per_token\": 0.000005,\n \"output_cost_per_token\": 0.00003,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-5.6-terra\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000012,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-1.5\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-2025-08-28\": {\n \"input_cost_per_token\": 0.0000025,\n \"output_cost_per_token\": 0.00001,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-mini\": {\n \"input_cost_per_token\": 6e-7,\n \"output_cost_per_token\": 0.0000024,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-mini-2025-10-06\": {\n \"input_cost_per_token\": 6e-7,\n \"output_cost_per_token\": 0.0000024,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"gpt-audio-mini-2025-12-15\": {\n \"input_cost_per_token\": 6e-7,\n \"output_cost_per_token\": 0.0000024,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"llama-3.1-8b-instant\": {\n \"input_cost_per_token\": 5e-8,\n \"output_cost_per_token\": 8e-8,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"llama-3.3-70b-versatile\": {\n \"input_cost_per_token\": 5.9e-7,\n \"output_cost_per_token\": 7.9e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"meta-llama/llama-4-scout-17b-16e-instruct\": {\n \"input_cost_per_token\": 1.1e-7,\n \"output_cost_per_token\": 3.4e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"o1\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o1-2024-12-17\": {\n \"input_cost_per_token\": 0.000015,\n \"output_cost_per_token\": 0.00006,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3-2025-04-16\": {\n \"input_cost_per_token\": 0.000002,\n \"output_cost_per_token\": 0.000008,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3-mini\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o3-mini-2025-01-31\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o4-mini\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"o4-mini-2025-04-16\": {\n \"input_cost_per_token\": 0.0000011,\n \"output_cost_per_token\": 0.0000044,\n \"litellm_provider\": \"openai\",\n \"mode\": \"chat\"\n },\n \"openai/gpt-oss-120b\": {\n \"input_cost_per_token\": 1.5e-7,\n \"output_cost_per_token\": 6e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"openai/gpt-oss-20b\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"openai/gpt-oss-safeguard-20b\": {\n \"input_cost_per_token\": 7.5e-8,\n \"output_cost_per_token\": 3e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"qwen/qwen3-32b\": {\n \"input_cost_per_token\": 2.9e-7,\n \"output_cost_per_token\": 5.9e-7,\n \"litellm_provider\": \"groq\",\n \"mode\": \"chat\"\n },\n \"text-embedding-3-large\": {\n \"input_cost_per_token\": 1.3e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"text-embedding-3-small\": {\n \"input_cost_per_token\": 2e-8,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"text-embedding-ada-002\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"text-embedding-ada-002-v2\": {\n \"input_cost_per_token\": 1e-7,\n \"output_cost_per_token\": 0,\n \"litellm_provider\": \"openai\",\n \"mode\": \"embedding\"\n },\n \"__voice__\": {\n \"deepgram-nova-3\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0001283333,\n \"provider\": \"deepgram\"\n },\n \"deepgram-nova-3-multilingual\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0001533333,\n \"provider\": \"deepgram\"\n },\n \"deepgram-nova-3-base\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0002416667,\n \"provider\": \"deepgram\"\n },\n \"assemblyai-universal-streaming\": {\n \"mode\": \"stt\",\n \"unit\": \"usd_per_second\",\n \"rate\": 0.0000416667,\n \"provider\": \"assemblyai\"\n },\n \"elevenlabs-multilingual-v2\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.1,\n \"provider\": \"elevenlabs\"\n },\n \"elevenlabs-flash-v2.5\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.05,\n \"provider\": \"elevenlabs\"\n },\n \"elevenlabs-turbo-v2.5\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.05,\n \"provider\": \"elevenlabs\"\n },\n \"cartesia-sonic\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.03,\n \"provider\": \"cartesia\"\n },\n \"cartesia-line\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.06,\n \"provider\": \"cartesia\"\n },\n \"rime-mist-v2\": {\n \"mode\": \"tts\",\n \"unit\": \"usd_per_1k_chars\",\n \"rate\": 0.03,\n \"provider\": \"rime\"\n },\n \"twilio-us-inbound-local\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.0085,\n \"provider\": \"twilio\"\n },\n \"twilio-us-outbound-local\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.014,\n \"provider\": \"twilio\"\n },\n \"twilio-us-sip-inbound\": {\n \"mode\": \"telephony\",\n \"unit\": \"usd_per_minute\",\n \"rate\": 0.004,\n \"provider\": \"twilio\"\n }\n },\n \"claude-3-5-sonnet-20241022\": {\n \"input_cost_per_token\": 3e-06,\n \"output_cost_per_token\": 1.5e-05,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-3-5-sonnet-20240620\": {\n \"input_cost_per_token\": 3e-06,\n \"output_cost_per_token\": 1.5e-05,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n },\n \"claude-3-5-haiku-20241022\": {\n \"input_cost_per_token\": 8e-07,\n \"output_cost_per_token\": 4e-06,\n \"litellm_provider\": \"anthropic\",\n \"mode\": \"chat\"\n }\n}\n","/**\n * Offline pricing for voice legs (STT / TTS / telephony) from the vendored map.\n *\n * The voice twin of `pricing.ts`. The token cost map is per-token; a voice\n * pipeline's bill is per-second (STT), per-1k-chars (TTS), and per-minute\n * (telephony) instead, so the voice rates live under the reserved `\"__voice__\"`\n * key of `cost_map.json` with their own schema:\n *\n * \"deepgram-nova-3\": {\n * \"mode\": \"stt\", // discriminator: \"stt\" | \"tts\" | \"telephony\"\n * \"unit\": \"usd_per_second\", // explicit unit — a mismatch fails closed\n * \"rate\": 0.0001283333, // USD in that unit\n * \"provider\": \"deepgram\"\n * }\n *\n * Same fail-closed contract as token pricing: a vendor absent from the map (or an\n * entry whose `unit`/`mode` does not match the leg it is asked to price) is\n * unpriceable — {@link lookupVoiceRate} returns `null` and the adapter throws\n * {@link UnpriceableVoiceError} rather than silently metering the leg at $0. Pass a\n * per-unit override to enforce a leg the map cannot price.\n *\n * No network. The rates are a **drift-prone snapshot** of each vendor's public\n * list price — refresh them (`scripts/update-cost-map.mjs`) like the token map, or\n * estimates drift as vendors change prices. Telephony is **US-only in v1**.\n *\n * This is a faithful port of `src/floe_guard/voice_pricing.py`.\n */\n\nimport costMapJson from \"./cost_map.json\";\nimport { UnpriceableVoiceError } from \"./errors.js\";\n\nexport type VoiceMode = \"stt\" | \"tts\" | \"telephony\";\n\ninterface VoiceMapEntry {\n mode?: unknown;\n unit?: unknown;\n rate?: unknown;\n provider?: unknown;\n}\n\n/** The vendored voice rates — the reserved `\"__voice__\"` section of the cost map. */\nconst VOICE_MAP = ((costMapJson as Record<string, unknown>)[\"__voice__\"] ?? {}) as Record<\n string,\n VoiceMapEntry\n>;\n\n/**\n * The one unit each leg is billed in. An entry whose `unit` disagrees with its\n * leg is a schema mismatch and fails closed — a Deepgram $/min figure stored\n * without the ÷60 conversion would over-bill 60x if it were silently accepted.\n */\nexport const unitForMode: Record<VoiceMode, string> = {\n stt: \"usd_per_second\",\n tts: \"usd_per_1k_chars\",\n telephony: \"usd_per_minute\",\n};\n\n/** A resolved per-unit voice rate plus where it came from. */\nexport interface VoiceRate {\n mode: string;\n unit: string;\n rate: number;\n source: \"override\" | \"cost_map\";\n}\n\nfunction finiteNonNegative(value: unknown): value is number {\n // typeof excludes booleans (Python's _finite_non_negative excludes bool too).\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0;\n}\n\n/**\n * Resolve a voice vendor to its per-unit rate, or `null` if unpriceable.\n *\n * The pure resolver (the voice twin of {@link resolvePrice}): it never throws.\n * Fail-closed on every mismatch — a missing vendor, an entry whose `mode` is not\n * `mode`, an entry whose `unit` is not the canonical unit for `mode`, or a\n * non-finite/negative rate — so a schema slip can never surface as a silent,\n * valid-looking price.\n */\nexport function lookupVoiceRate(model: string | null | undefined, mode: VoiceMode): number | null {\n if (model === null || model === undefined) return null;\n const entry = Object.prototype.hasOwnProperty.call(VOICE_MAP, model)\n ? VOICE_MAP[model]\n : undefined;\n if (!entry) return null;\n if (entry.mode !== mode) return null;\n if (entry.unit !== unitForMode[mode]) return null;\n const rate = entry.rate;\n if (!finiteNonNegative(rate)) return null;\n return rate;\n}\n\n/**\n * Resolve a leg's per-unit rate, fail-closed. An `override` wins over the map.\n *\n * Throws {@link UnpriceableVoiceError} when neither an override nor the bundled\n * map can price the leg — the guard refuses to meter spend it cannot measure.\n */\nexport function resolveVoiceRate(\n model: string | null | undefined,\n mode: VoiceMode,\n override?: number | null,\n): VoiceRate {\n if (override !== undefined && override !== null) {\n if (!finiteNonNegative(override)) {\n throw new RangeError(\n `voice ${mode} override must be a finite, non-negative number, got ${override}`,\n );\n }\n return { mode, unit: unitForMode[mode], rate: override, source: \"override\" };\n }\n const rate = lookupVoiceRate(model, mode);\n if (rate === null) throw new UnpriceableVoiceError(model ?? null, mode);\n return { mode, unit: unitForMode[mode], rate, source: \"cost_map\" };\n}\n\n/**\n * USD for one leg. `quantity` is seconds (stt), characters (tts), or minutes\n * (telephony); negative quantities clamp to zero.\n */\nexport function voiceLegCost(mode: VoiceMode, quantity: number, rate: number): number {\n // Reject non-finite quantities: Math.max(0, NaN) is NaN, so a NaN/Infinity\n // quantity would return a non-finite USD amount that then poisons the guard's\n // running total (NaN disables every ceiling comparison). Negatives still clamp.\n if (!Number.isFinite(quantity)) {\n throw new RangeError(`voice ${mode} quantity must be a finite number, got ${quantity}`);\n }\n const q = Math.max(0, quantity);\n if (mode === \"stt\") return q * rate; // seconds * $/second\n if (mode === \"tts\") return (q / 1000) * rate; // chars / 1000 * $/1k-chars\n if (mode === \"telephony\") return q * rate; // minutes * $/minute\n throw new RangeError(`unknown voice mode ${mode}`);\n}\n\n/**\n * USD for one voice leg, or `null` when the leg is unconfigured (skip it).\n *\n * The single entry point the adapters use. A leg with neither a vendor (`model`)\n * nor an `override` is unconfigured — return `null` so the token-only contract is\n * preserved and nothing is metered. A leg that *is* configured but cannot be\n * priced throws {@link UnpriceableVoiceError} (via {@link resolveVoiceRate}) rather\n * than accruing a silent $0.\n */\nexport function priceVoiceLeg(\n mode: VoiceMode,\n quantity: number,\n options: { model?: string | null; override?: number | null } = {},\n): number | null {\n const model = options.model ?? null;\n const override = options.override ?? null;\n if (model === null && override === null) return null;\n const resolved = resolveVoiceRate(model, mode, override);\n return voiceLegCost(mode, quantity, resolved.rate);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAQO,IAAM,iBAAN,cAA6B,eAAe;AAAA,EACxC;AAAA,EACA;AAAA,EAET,YAAY,UAAkB,UAAkB,SAAkB;AAGhE;AAAA,MACE,WACE,+CAA0C,SAAS,QAAQ,CAAC,CAAC,QAAQ,SAAS,QAAQ,CAAC,CAAC;AAAA,IAC5F;AACA,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,WAAW;AAAA,EAClB;AACF;AAsEO,IAAM,wBAAN,cAAoC,eAAe;AAAA,EAC/C;AAAA,EACA;AAAA,EAET,YAAY,QAAuB,MAAc;AAE/C,UAAM,QAAQ,WAAW,OAAO,SAAS,IAAI,MAAM;AACnD;AAAA,MACE,gBAAgB,IAAI,WAAW,KAAK,8EACY,IAAI;AAAA,IAGtD;AACA,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;;;ACtFO,SAAS,gBACd,OACA,UAAyC,CAAC,GACjC;AAIT,QAAM,mBAAmB,QAAQ,qBAAqB,SAAY,IAAI,QAAQ;AAC9E,MAAI,CAAC,OAAO,SAAS,gBAAgB,KAAK,mBAAmB,GAAG;AAC9D,UAAM,IAAI;AAAA,MACR,+DAA+D,gBAAgB;AAAA,IACjF;AAAA,EACF;AACA,QAAM,eAAe,MAAM;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AAK,MAAM,OAAO,GAAG;AACtC,UAAI,KAAK,KAAM,MAAK,MAAM,QAAQ,KAAK,MAAM;AAAA,IAC/C;AACA,SAAK,MAAM,MAAM;AACjB,SAAK,mBAAmB;AAAA,EAC1B;AAAA;AAAA,EAGQ,cAAc,UAAwB;AAC5C,UAAM,KAAK,KAAK;AAChB,QAAI,OAAO,QAAQ,OAAO,SAAU;AACpC,UAAM,OAAO,KAAK,MAAM,IAAI,EAAE;AAC9B,QAAI,SAAS,UAAa,KAAK,MAAM;AACnC,WAAK,MAAM,QAAQ,KAAK,MAAM;AAC9B,WAAK,OAAO;AACZ,WAAK,MAAM,OAAO,EAAE;AAAA,IACtB;AACA,SAAK,mBAAmB;AAAA,EAC1B;AACF;","names":[]}
|
package/dist/adapters/retell.js
CHANGED
package/dist/adapters/vapi.cjs
CHANGED
|
@@ -1169,6 +1169,24 @@ var cost_map_default = {
|
|
|
1169
1169
|
rate: 4e-3,
|
|
1170
1170
|
provider: "twilio"
|
|
1171
1171
|
}
|
|
1172
|
+
},
|
|
1173
|
+
"claude-3-5-sonnet-20241022": {
|
|
1174
|
+
input_cost_per_token: 3e-6,
|
|
1175
|
+
output_cost_per_token: 15e-6,
|
|
1176
|
+
litellm_provider: "anthropic",
|
|
1177
|
+
mode: "chat"
|
|
1178
|
+
},
|
|
1179
|
+
"claude-3-5-sonnet-20240620": {
|
|
1180
|
+
input_cost_per_token: 3e-6,
|
|
1181
|
+
output_cost_per_token: 15e-6,
|
|
1182
|
+
litellm_provider: "anthropic",
|
|
1183
|
+
mode: "chat"
|
|
1184
|
+
},
|
|
1185
|
+
"claude-3-5-haiku-20241022": {
|
|
1186
|
+
input_cost_per_token: 8e-7,
|
|
1187
|
+
output_cost_per_token: 4e-6,
|
|
1188
|
+
litellm_provider: "anthropic",
|
|
1189
|
+
mode: "chat"
|
|
1172
1190
|
}
|
|
1173
1191
|
};
|
|
1174
1192
|
|