MCPcopy Create free account
hub / github.com/pollinations/pollinations / buildUsageHeaders

Function buildUsageHeaders

shared/registry/usage-headers.ts:238–254  ·  view source on GitHub ↗
(
    modelUsed: string,
    usage: Usage,
)

Source from the content-addressed store, hash-verified

236 * Returns headers with x-usage-* prefix for all non-zero usage types
237 */
238export function buildUsageHeaders(
239 modelUsed: string,
240 usage: Usage,
241): Record<string, string> {
242 const headers: Record<string, string> = {
243 "x-model-used": modelUsed,
244 };
245
246 for (const [usageType, headerName] of Object.entries(USAGE_TYPE_HEADERS)) {
247 const value = usage[usageType as UsageType];
248 if (value && value > 0) {
249 headers[headerName] = String(value);
250 }
251 }
252
253 return headers;
254}
255
256/**
257 * Parse usage headers back to Usage object

Callers 15

embeddingsResponseFunction · 0.90
buildTrackingHeadersFunction · 0.90
transcribeWithAssemblyAiFunction · 0.90
generateSpeechFunction · 0.90
transcribeWithElevenLabsFunction · 0.90
generateMusicFunction · 0.90
generateSoundEffectFunction · 0.90
generateQwenTtsFunction · 0.90
generateAceStepMusicFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected