MCPcopy Create free account
hub / github.com/TanStack/ai / createBillingFetch

Function createBillingFetch

packages/ai-fal/src/utils/billing.ts:105–117  ·  view source on GitHub ↗
(
  baseFetch: typeof fetch = globalThis.fetch,
)

Source from the content-addressed store, hash-verified

103 * mutating any global.
104 */
105export function createBillingFetch(
106 baseFetch: typeof fetch = globalThis.fetch,
107): typeof fetch {
108 return async (input, init) => {
109 const response = await baseFetch(input, init)
110 try {
111 recordBillableUnitsFromResponse(response)
112 } catch {
113 // Capturing usage must never break the underlying request.
114 }
115 return response
116 }
117}

Callers 2

configureFalClientFunction · 0.90
billing.test.tsFile · 0.90

Calls 1

Tested by

no test coverage detected