@standardagents/provider-pricing
v0.40.6
Published
Pure provider pricing tables and cost helpers for Standard Agents
Readme
@standardagents/provider-pricing
Pure provider pricing tables and cost helpers for Standard Agents.
This package contains no provider SDKs and no runtime network calls. It is the
shared pricing source for provider packages, builder request logs, and hosted
platform accounting. Unknown model prices return undefined; callers that bill
money must fail closed instead of guessing.
import { calculateCerebrasUsageCost } from '@standardagents/provider-pricing';
const cost = calculateCerebrasUsageCost('zai-glm-4.7', {
promptTokens: 6298,
completionTokens: 284,
});For platform accounting, use the integer microcent helpers to avoid floating point rounding drift. Pass provider-specific billing fields through instead of flattening them: Google modality token details, generated image counts, Anthropic cache-write/read buckets, OpenAI long-context thresholds, cached tokens, and reasoning tokens all affect exact cost for at least one provider.
OpenAI entries track the standard token-pricing table from the official developer pricing page. They intentionally do not model Batch, Flex, Priority, regional uplift, hosted tool call fees, image-generation calculator pricing, or audio pricing; billing callers must reject those paths or account for them separately.
import { calculateProviderUsageCostMicrocents } from '@standardagents/provider-pricing';
const microcents = calculateProviderUsageCostMicrocents('cerebras', 'zai-glm-4.7', {
input_tokens: 6298,
output_tokens: 284,
});