MCPcopy Create free account
hub / github.com/code-with-antonio/nightcode / convertUsdToCredits

Function convertUsdToCredits

packages/server/src/lib/credits.ts:75–83  ·  view source on GitHub ↗
(estimatedCostUsd: number)

Source from the content-addressed store, hash-verified

73};
74
75function convertUsdToCredits(estimatedCostUsd: number) {
76 if (estimatedCostUsd <= 0) {
77 return 0;
78 }
79
80 // If a request costs any non-zero amount, charge at least 1 credit, then
81 // round up so partial credits always become a whole credit.
82 return Math.max(1, Math.ceil(estimatedCostUsd / USD_PER_CREDIT));
83};
84
85
86export function calculateCreditsForUsage({

Callers 1

calculateCreditsForUsageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected