Download src/server/usage/pricing.ts from bhyve/auto-lms: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/bhyve/auto-lms/resolve/main/src/server/usage/pricing.ts
- Command line
-
hf download hf://spaces/bhyve/auto-lms/src/server/usage/pricing.ts
-
curl -L -o pricing.ts https://huggingface.co/spaces/bhyve/auto-lms/resolve/main/src/server/usage/pricing.ts
1.14 kB
| // Estimated public Gemini API pricing in USD. These are PLACEHOLDER figures — | |
| // verify against https://ai.google.dev/gemini-api/docs/pricing and update before | |
| // relying on the cost numbers. Centralised here so cost math is never inlined. | |
| export interface ModelPricing { | |
| inputPerMillion: number; // USD per 1M input tokens | |
| outputPerMillion: number; // USD per 1M output tokens | |
| } | |
| export const MODEL_PRICING: Record<string, ModelPricing> = { | |
| 'gemini-2.5-flash': { inputPerMillion: 0.3, outputPerMillion: 2.5 }, | |
| 'gemini-2.5-pro': { inputPerMillion: 1.25, outputPerMillion: 10.0 }, | |
| // TTS bills output as audio tokens; treat candidates tokens as output. | |
| 'gemini-2.5-flash-preview-tts': { inputPerMillion: 0.5, outputPerMillion: 10.0 }, | |
| }; | |
| const ZERO_PRICING: ModelPricing = { inputPerMillion: 0, outputPerMillion: 0 }; | |
| export function estimateCostUsd( | |
| model: string, | |
| promptTokens: number, | |
| completionTokens: number, | |
| ): number { | |
| const pricing = MODEL_PRICING[model] ?? ZERO_PRICING; | |
| return ( | |
| (promptTokens / 1_000_000) * pricing.inputPerMillion + | |
| (completionTokens / 1_000_000) * pricing.outputPerMillion | |
| ); | |
| } | |