estimateCostUsd (lib/llmPricing.ts)

mockserver-monorepo · mockserver-ui/src/lib/llmPricing.ts · typescript · Apache-2.0
ai

Calculates estimated USD cost for LLM API usage based on provider and model.

// Source: https://github.com/mock-server/mockserver-monorepo | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Estimated cost calculation for LLM API usage.
 *
 * Pure function that consults a pricing table keyed on (provider, model)
 * with inputPerMillion and outputPerMillion rates in USD.
 *
 * Returns null for unknown models so the UI can display "—".
 *
 * Pricing source / freshness
 * --------------------------
 * Rates below are public provider list prices captured 2026-06 (newer
 * families) / 2025-Q4 (original entries). They WILL drift; treat the
 * dashboard total as an estimate, not an invoice.
 * Refresh procedure: update the relevant `*_PRICING` array entry and


... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key