MCPcopy Index your code
hub / github.com/simstudioai/sim / parseBillingEvent

Function parseBillingEvent

apps/sim/lib/tools/falai-pricing.ts:64–82  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

62}
63
64function parseBillingEvent(value: unknown): FalAIBillingEvent | undefined {
65 if (!isRecordLike(value)) return undefined
66
67 const requestId = value.request_id
68 const endpointId = value.endpoint_id
69 const costEstimateNanoUsd = getNumber(value.cost_estimate_nano_usd)
70
71 if (typeof requestId !== 'string' || typeof endpointId !== 'string') return undefined
72 if (costEstimateNanoUsd === undefined) return undefined
73
74 return {
75 request_id: requestId,
76 endpoint_id: endpointId,
77 output_units: getNumber(value.output_units) ?? null,
78 unit_price: getNumber(value.unit_price) ?? null,
79 percent_discount: getNumber(value.percent_discount) ?? null,
80 cost_estimate_nano_usd: costEstimateNanoUsd,
81 }
82}
83
84async function fetchFalAIBillingEvent(
85 apiKey: string,

Callers

nothing calls this directly

Calls 2

isRecordLikeFunction · 0.90
getNumberFunction · 0.70

Tested by

no test coverage detected