@standardagents/provider-pricing 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.js +742 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @standardagents/provider-pricing
|
|
2
|
+
|
|
3
|
+
Pure provider pricing tables and cost helpers for Standard Agents.
|
|
4
|
+
|
|
5
|
+
This package contains no provider SDKs and no runtime network calls. It is the
|
|
6
|
+
shared pricing source for provider packages, builder request logs, and hosted
|
|
7
|
+
platform accounting. Unknown model prices return `undefined`; callers that bill
|
|
8
|
+
money must fail closed instead of guessing.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { calculateCerebrasUsageCost } from '@standardagents/provider-pricing';
|
|
12
|
+
|
|
13
|
+
const cost = calculateCerebrasUsageCost('zai-glm-4.7', {
|
|
14
|
+
promptTokens: 6298,
|
|
15
|
+
completionTokens: 284,
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For platform accounting, use the integer microcent helpers to avoid floating
|
|
20
|
+
point rounding drift. Pass provider-specific billing fields through instead of
|
|
21
|
+
flattening them: Google modality token details, generated image counts,
|
|
22
|
+
Anthropic cache-write/read buckets, OpenAI long-context thresholds, cached
|
|
23
|
+
tokens, and reasoning tokens all affect exact cost for at least one provider.
|
|
24
|
+
|
|
25
|
+
OpenAI entries track the standard token-pricing table from the official
|
|
26
|
+
developer pricing page. They intentionally do not model Batch, Flex, Priority,
|
|
27
|
+
regional uplift, hosted tool call fees, image-generation calculator pricing, or
|
|
28
|
+
audio pricing; billing callers must reject those paths or account for them
|
|
29
|
+
separately.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { calculateProviderUsageCostMicrocents } from '@standardagents/provider-pricing';
|
|
33
|
+
|
|
34
|
+
const microcents = calculateProviderUsageCostMicrocents('cerebras', 'zai-glm-4.7', {
|
|
35
|
+
input_tokens: 6298,
|
|
36
|
+
output_tokens: 284,
|
|
37
|
+
});
|
|
38
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
declare const MICROCENTS_PER_DOLLAR = 100000000;
|
|
2
|
+
type ProviderPricingName = 'anthropic' | 'cerebras' | 'cloudflare' | 'google' | 'groq' | 'openai' | 'xai';
|
|
3
|
+
interface ProviderUsageLike {
|
|
4
|
+
promptTokens: number;
|
|
5
|
+
completionTokens: number;
|
|
6
|
+
cachedTokens?: number;
|
|
7
|
+
reasoningTokens?: number;
|
|
8
|
+
}
|
|
9
|
+
interface PlatformTokenUsageLike {
|
|
10
|
+
input_tokens: number;
|
|
11
|
+
output_tokens: number;
|
|
12
|
+
cached_tokens?: number;
|
|
13
|
+
reasoning_tokens?: number;
|
|
14
|
+
prompt_token_details?: GoogleModalityTokenCount[];
|
|
15
|
+
completion_token_details?: GoogleModalityTokenCount[];
|
|
16
|
+
cached_token_details?: GoogleModalityTokenCount[];
|
|
17
|
+
image_count?: number;
|
|
18
|
+
cache_creation_input_tokens?: number;
|
|
19
|
+
cache_creation_5m_input_tokens?: number;
|
|
20
|
+
cache_creation_1h_input_tokens?: number;
|
|
21
|
+
cache_read_input_tokens?: number;
|
|
22
|
+
}
|
|
23
|
+
interface ProviderModelPricing {
|
|
24
|
+
inputPerMillion: number;
|
|
25
|
+
outputPerMillion: number;
|
|
26
|
+
cachedInputPerMillion?: number;
|
|
27
|
+
longInputPerMillion?: number;
|
|
28
|
+
longOutputPerMillion?: number;
|
|
29
|
+
longCachedInputPerMillion?: number;
|
|
30
|
+
longContextThreshold?: number;
|
|
31
|
+
maxTokens?: number;
|
|
32
|
+
source: `${ProviderPricingName}-static`;
|
|
33
|
+
}
|
|
34
|
+
interface AnthropicModelPricing {
|
|
35
|
+
inputPerMillion: number;
|
|
36
|
+
outputPerMillion: number;
|
|
37
|
+
}
|
|
38
|
+
interface AnthropicUsageBuckets {
|
|
39
|
+
inputTokens: number;
|
|
40
|
+
outputTokens: number;
|
|
41
|
+
cacheReadTokens: number;
|
|
42
|
+
cacheWrite5mTokens: number;
|
|
43
|
+
cacheWrite1hTokens: number;
|
|
44
|
+
}
|
|
45
|
+
interface CerebrasModelPricing {
|
|
46
|
+
inputPerMillion: number;
|
|
47
|
+
outputPerMillion: number;
|
|
48
|
+
maxTokens?: number;
|
|
49
|
+
}
|
|
50
|
+
type GooglePricingModality = 'text' | 'image' | 'video' | 'audio' | 'document' | 'unspecified';
|
|
51
|
+
interface GoogleModalityTokenCount {
|
|
52
|
+
modality?: string;
|
|
53
|
+
tokenCount?: number;
|
|
54
|
+
}
|
|
55
|
+
interface GoogleModelPricing {
|
|
56
|
+
inputPerMillion: number;
|
|
57
|
+
longInputPerMillion?: number;
|
|
58
|
+
outputPerMillion?: number;
|
|
59
|
+
longOutputPerMillion?: number;
|
|
60
|
+
cachedInputPerMillion?: number;
|
|
61
|
+
longCachedInputPerMillion?: number;
|
|
62
|
+
outputImagePerImage?: number;
|
|
63
|
+
inputByModalityPerMillion?: Partial<Record<GooglePricingModality, number>>;
|
|
64
|
+
outputByModalityPerMillion?: Partial<Record<GooglePricingModality, number>>;
|
|
65
|
+
cachedByModalityPerMillion?: Partial<Record<GooglePricingModality, number>>;
|
|
66
|
+
longContextThreshold?: number;
|
|
67
|
+
}
|
|
68
|
+
interface GroqModelPricing {
|
|
69
|
+
inputPerMillion: number;
|
|
70
|
+
outputPerMillion: number;
|
|
71
|
+
cachedInputPerMillion?: number;
|
|
72
|
+
}
|
|
73
|
+
interface OpenAIModelPricing {
|
|
74
|
+
inputPerMillion: number;
|
|
75
|
+
outputPerMillion: number;
|
|
76
|
+
cachedInputPerMillion?: number;
|
|
77
|
+
longInputPerMillion?: number;
|
|
78
|
+
longOutputPerMillion?: number;
|
|
79
|
+
longCachedInputPerMillion?: number;
|
|
80
|
+
longContextThreshold?: number;
|
|
81
|
+
}
|
|
82
|
+
interface XAITextPricing {
|
|
83
|
+
inputPerMillion: number;
|
|
84
|
+
outputPerMillion: number;
|
|
85
|
+
cachedInputPerMillion?: number;
|
|
86
|
+
}
|
|
87
|
+
interface CloudflareModelPricing {
|
|
88
|
+
inputPerMillion: number;
|
|
89
|
+
outputPerMillion: number;
|
|
90
|
+
cachedInputPerMillion?: number;
|
|
91
|
+
}
|
|
92
|
+
declare function getAnthropicModelPricing(modelId: string | null | undefined): AnthropicModelPricing | null;
|
|
93
|
+
declare function calculateAnthropicUsageCost(modelId: string | null | undefined, buckets: AnthropicUsageBuckets): number | undefined;
|
|
94
|
+
declare function getCerebrasModelPricing(modelId: string | null | undefined): CerebrasModelPricing | undefined;
|
|
95
|
+
declare function calculateCerebrasUsageCost(modelId: string | null | undefined, usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens'>): number | undefined;
|
|
96
|
+
declare function getGoogleModelPricing(modelId: string): GoogleModelPricing | undefined;
|
|
97
|
+
declare function calculateGoogleUsageCost(modelId: string, usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'reasoningTokens' | 'cachedTokens'> & {
|
|
98
|
+
promptTokenDetails?: GoogleModalityTokenCount[];
|
|
99
|
+
completionTokenDetails?: GoogleModalityTokenCount[];
|
|
100
|
+
cachedTokenDetails?: GoogleModalityTokenCount[];
|
|
101
|
+
}, imageCount?: number): number | undefined;
|
|
102
|
+
declare function getOpenAIModelPricing(modelId: string): OpenAIModelPricing | undefined;
|
|
103
|
+
declare function calculateOpenAIUsageCost(modelId: string, usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>): number | undefined;
|
|
104
|
+
declare function getGroqModelPricing(modelId: string): GroqModelPricing | undefined;
|
|
105
|
+
declare function calculateGroqUsageCost(modelId: string, usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>): number | undefined;
|
|
106
|
+
declare function getXAITextPricing(modelId: string): XAITextPricing | undefined;
|
|
107
|
+
declare function calculateXAIUsageCost(modelId: string, usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>): number | undefined;
|
|
108
|
+
declare function ticksToUsd(ticks: number | undefined): number | undefined;
|
|
109
|
+
declare function getCloudflareModelPricing(modelId: string): CloudflareModelPricing | undefined;
|
|
110
|
+
declare function calculateCloudflareUsageCost(modelId: string, usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>): number | undefined;
|
|
111
|
+
declare function getProviderModelPricing(provider: ProviderPricingName, modelId: string | null | undefined): ProviderModelPricing | undefined;
|
|
112
|
+
declare function calculateProviderUsageCostMicrocents(provider: ProviderPricingName, modelId: string, usage: PlatformTokenUsageLike): number | undefined;
|
|
113
|
+
|
|
114
|
+
export { type AnthropicModelPricing, type AnthropicUsageBuckets, type CerebrasModelPricing, type CloudflareModelPricing, type GoogleModalityTokenCount, type GoogleModelPricing, type GroqModelPricing, MICROCENTS_PER_DOLLAR, type OpenAIModelPricing, type PlatformTokenUsageLike, type ProviderModelPricing, type ProviderPricingName, type ProviderUsageLike, type XAITextPricing, calculateAnthropicUsageCost, calculateCerebrasUsageCost, calculateCloudflareUsageCost, calculateGoogleUsageCost, calculateGroqUsageCost, calculateOpenAIUsageCost, calculateProviderUsageCostMicrocents, calculateXAIUsageCost, getAnthropicModelPricing, getCerebrasModelPricing, getCloudflareModelPricing, getGoogleModelPricing, getGroqModelPricing, getOpenAIModelPricing, getProviderModelPricing, getXAITextPricing, ticksToUsd };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var TOKENS_PER_MILLION = 1e6;
|
|
3
|
+
var MICROCENTS_PER_DOLLAR = 1e8;
|
|
4
|
+
var XAI_TICKS_PER_DOLLAR = 1e10;
|
|
5
|
+
var ANTHROPIC_MODEL_PRICING = [
|
|
6
|
+
["claude-fable-5", { inputPerMillion: 10, outputPerMillion: 50 }],
|
|
7
|
+
["claude-mythos", { inputPerMillion: 10, outputPerMillion: 50 }],
|
|
8
|
+
["claude-opus-4-8", { inputPerMillion: 5, outputPerMillion: 25 }],
|
|
9
|
+
["claude-opus-4-7", { inputPerMillion: 5, outputPerMillion: 25 }],
|
|
10
|
+
["claude-opus-4-6", { inputPerMillion: 5, outputPerMillion: 25 }],
|
|
11
|
+
["claude-opus-4-5", { inputPerMillion: 5, outputPerMillion: 25 }],
|
|
12
|
+
["claude-opus-4-1", { inputPerMillion: 15, outputPerMillion: 75 }],
|
|
13
|
+
["claude-opus-4", { inputPerMillion: 15, outputPerMillion: 75 }],
|
|
14
|
+
["claude-sonnet-4-6", { inputPerMillion: 3, outputPerMillion: 15 }],
|
|
15
|
+
["claude-sonnet-4-5", { inputPerMillion: 3, outputPerMillion: 15 }],
|
|
16
|
+
["claude-sonnet-4", { inputPerMillion: 3, outputPerMillion: 15 }],
|
|
17
|
+
["claude-haiku-4-5", { inputPerMillion: 1, outputPerMillion: 5 }],
|
|
18
|
+
["claude-3-7-sonnet", { inputPerMillion: 3, outputPerMillion: 15 }],
|
|
19
|
+
["claude-3-5-sonnet", { inputPerMillion: 3, outputPerMillion: 15 }],
|
|
20
|
+
["claude-3-5-haiku", { inputPerMillion: 0.8, outputPerMillion: 4 }],
|
|
21
|
+
["claude-3-opus", { inputPerMillion: 15, outputPerMillion: 75 }],
|
|
22
|
+
["claude-3-haiku", { inputPerMillion: 0.25, outputPerMillion: 1.25 }]
|
|
23
|
+
];
|
|
24
|
+
var CEREBRAS_MODEL_PRICING = {
|
|
25
|
+
"zai-glm-4.7": { inputPerMillion: 2.25, outputPerMillion: 2.75, maxTokens: 64e3 },
|
|
26
|
+
"gpt-oss-120b": { inputPerMillion: 0.35, outputPerMillion: 0.75, maxTokens: 64e3 },
|
|
27
|
+
"llama3.1-8b": { inputPerMillion: 0.1, outputPerMillion: 0.1, maxTokens: 8192 },
|
|
28
|
+
"qwen-3-235b-a22b-instruct-2507": { inputPerMillion: 0.6, outputPerMillion: 1.2, maxTokens: 40960 },
|
|
29
|
+
"gemma-4-31b": { inputPerMillion: 0.99, outputPerMillion: 1.49, maxTokens: 4096 }
|
|
30
|
+
};
|
|
31
|
+
var GOOGLE_MODEL_PRICING = {
|
|
32
|
+
"gemini-3-pro-preview": {
|
|
33
|
+
inputPerMillion: 2,
|
|
34
|
+
outputPerMillion: 12,
|
|
35
|
+
cachedInputPerMillion: 0.2
|
|
36
|
+
},
|
|
37
|
+
"gemini-3.1-pro-preview": {
|
|
38
|
+
inputPerMillion: 2,
|
|
39
|
+
longInputPerMillion: 4,
|
|
40
|
+
outputPerMillion: 12,
|
|
41
|
+
longOutputPerMillion: 18,
|
|
42
|
+
cachedInputPerMillion: 0.2,
|
|
43
|
+
longCachedInputPerMillion: 0.4,
|
|
44
|
+
longContextThreshold: 2e5
|
|
45
|
+
},
|
|
46
|
+
"gemini-2.5-pro": {
|
|
47
|
+
inputPerMillion: 1.25,
|
|
48
|
+
longInputPerMillion: 2.5,
|
|
49
|
+
outputPerMillion: 10,
|
|
50
|
+
longOutputPerMillion: 15,
|
|
51
|
+
cachedInputPerMillion: 0.125,
|
|
52
|
+
longCachedInputPerMillion: 0.25,
|
|
53
|
+
longContextThreshold: 2e5
|
|
54
|
+
},
|
|
55
|
+
"gemini-2.5-flash": {
|
|
56
|
+
inputPerMillion: 0.3,
|
|
57
|
+
outputPerMillion: 2.5,
|
|
58
|
+
cachedInputPerMillion: 0.03
|
|
59
|
+
},
|
|
60
|
+
"gemini-2.5-flash-lite": {
|
|
61
|
+
inputPerMillion: 0.1,
|
|
62
|
+
outputPerMillion: 0.4,
|
|
63
|
+
cachedInputPerMillion: 0.01
|
|
64
|
+
},
|
|
65
|
+
"gemini-3-flash-preview": {
|
|
66
|
+
inputPerMillion: 0.5,
|
|
67
|
+
outputPerMillion: 3,
|
|
68
|
+
cachedInputPerMillion: 0.05,
|
|
69
|
+
inputByModalityPerMillion: {
|
|
70
|
+
text: 0.5,
|
|
71
|
+
image: 0.5,
|
|
72
|
+
video: 0.5,
|
|
73
|
+
audio: 1
|
|
74
|
+
},
|
|
75
|
+
cachedByModalityPerMillion: {
|
|
76
|
+
text: 0.05,
|
|
77
|
+
image: 0.05,
|
|
78
|
+
video: 0.05,
|
|
79
|
+
audio: 0.1
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"gemini-3.1-flash-lite-preview": {
|
|
83
|
+
inputPerMillion: 0.25,
|
|
84
|
+
outputPerMillion: 1.5,
|
|
85
|
+
cachedInputPerMillion: 0.025,
|
|
86
|
+
inputByModalityPerMillion: {
|
|
87
|
+
text: 0.25,
|
|
88
|
+
image: 0.25,
|
|
89
|
+
video: 0.25,
|
|
90
|
+
audio: 0.5
|
|
91
|
+
},
|
|
92
|
+
cachedByModalityPerMillion: {
|
|
93
|
+
text: 0.025,
|
|
94
|
+
image: 0.025,
|
|
95
|
+
video: 0.025,
|
|
96
|
+
audio: 0.05
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"deep-research-pro-preview-12-2025": {
|
|
100
|
+
inputPerMillion: 2,
|
|
101
|
+
outputPerMillion: 12,
|
|
102
|
+
cachedInputPerMillion: 0.2
|
|
103
|
+
},
|
|
104
|
+
"gemini-2.0-flash": {
|
|
105
|
+
inputPerMillion: 0.1,
|
|
106
|
+
outputPerMillion: 0.4,
|
|
107
|
+
cachedInputPerMillion: 0.025,
|
|
108
|
+
inputByModalityPerMillion: {
|
|
109
|
+
text: 0.1,
|
|
110
|
+
image: 0.1,
|
|
111
|
+
video: 0.1,
|
|
112
|
+
audio: 0.7
|
|
113
|
+
},
|
|
114
|
+
cachedByModalityPerMillion: {
|
|
115
|
+
text: 0.025,
|
|
116
|
+
image: 0.025,
|
|
117
|
+
video: 0.025,
|
|
118
|
+
audio: 0.175
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"gemini-2.0-flash-001": {
|
|
122
|
+
inputPerMillion: 0.1,
|
|
123
|
+
outputPerMillion: 0.4,
|
|
124
|
+
cachedInputPerMillion: 0.025,
|
|
125
|
+
inputByModalityPerMillion: {
|
|
126
|
+
text: 0.1,
|
|
127
|
+
image: 0.1,
|
|
128
|
+
video: 0.1,
|
|
129
|
+
audio: 0.7
|
|
130
|
+
},
|
|
131
|
+
cachedByModalityPerMillion: {
|
|
132
|
+
text: 0.025,
|
|
133
|
+
image: 0.025,
|
|
134
|
+
video: 0.025,
|
|
135
|
+
audio: 0.175
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"gemini-2.0-flash-lite": {
|
|
139
|
+
inputPerMillion: 0.075,
|
|
140
|
+
outputPerMillion: 0.3
|
|
141
|
+
},
|
|
142
|
+
"gemini-2.0-flash-lite-001": {
|
|
143
|
+
inputPerMillion: 0.075,
|
|
144
|
+
outputPerMillion: 0.3
|
|
145
|
+
},
|
|
146
|
+
"gemini-2.5-computer-use-preview-10-2025": {
|
|
147
|
+
inputPerMillion: 1.25,
|
|
148
|
+
longInputPerMillion: 2.5,
|
|
149
|
+
outputPerMillion: 10,
|
|
150
|
+
longOutputPerMillion: 15,
|
|
151
|
+
longContextThreshold: 2e5
|
|
152
|
+
},
|
|
153
|
+
"gemini-2.5-flash-preview-tts": {
|
|
154
|
+
inputPerMillion: 0.5,
|
|
155
|
+
outputPerMillion: 10,
|
|
156
|
+
outputByModalityPerMillion: {
|
|
157
|
+
audio: 10
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"gemini-2.5-pro-preview-tts": {
|
|
161
|
+
inputPerMillion: 1,
|
|
162
|
+
outputPerMillion: 20,
|
|
163
|
+
outputByModalityPerMillion: {
|
|
164
|
+
audio: 20
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"gemini-robotics-er-1.5-preview": {
|
|
168
|
+
inputPerMillion: 0.3,
|
|
169
|
+
outputPerMillion: 2.5,
|
|
170
|
+
inputByModalityPerMillion: {
|
|
171
|
+
text: 0.3,
|
|
172
|
+
image: 0.3,
|
|
173
|
+
video: 0.3,
|
|
174
|
+
audio: 1
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"gemini-2.5-flash-image": {
|
|
178
|
+
inputPerMillion: 0.3,
|
|
179
|
+
outputImagePerImage: 0.039
|
|
180
|
+
},
|
|
181
|
+
"gemini-3.1-flash-image-preview": {
|
|
182
|
+
inputPerMillion: 0.5,
|
|
183
|
+
outputPerMillion: 3,
|
|
184
|
+
outputImagePerImage: 0.045
|
|
185
|
+
},
|
|
186
|
+
"gemini-3-pro-image-preview": {
|
|
187
|
+
inputPerMillion: 2,
|
|
188
|
+
outputPerMillion: 12,
|
|
189
|
+
outputImagePerImage: 0.134
|
|
190
|
+
},
|
|
191
|
+
"nano-banana-pro-preview": {
|
|
192
|
+
inputPerMillion: 2,
|
|
193
|
+
outputPerMillion: 12,
|
|
194
|
+
outputImagePerImage: 0.134
|
|
195
|
+
},
|
|
196
|
+
"imagen-4.0-generate-001": {
|
|
197
|
+
inputPerMillion: 0,
|
|
198
|
+
outputImagePerImage: 0.04
|
|
199
|
+
},
|
|
200
|
+
"imagen-4.0-fast-generate-001": {
|
|
201
|
+
inputPerMillion: 0,
|
|
202
|
+
outputImagePerImage: 0.02
|
|
203
|
+
},
|
|
204
|
+
"imagen-4.0-ultra-generate-001": {
|
|
205
|
+
inputPerMillion: 0,
|
|
206
|
+
outputImagePerImage: 0.06
|
|
207
|
+
},
|
|
208
|
+
"imagen-3.0-capability-001": {
|
|
209
|
+
inputPerMillion: 0,
|
|
210
|
+
outputImagePerImage: 0.04
|
|
211
|
+
},
|
|
212
|
+
"gemma-4-31b-it": {
|
|
213
|
+
inputPerMillion: 0,
|
|
214
|
+
outputPerMillion: 0,
|
|
215
|
+
cachedInputPerMillion: 0
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
var GOOGLE_MODEL_PRICING_PREFIXES = [
|
|
219
|
+
{ prefix: "gemini-3.1-pro-preview", pricing: GOOGLE_MODEL_PRICING["gemini-3.1-pro-preview"] },
|
|
220
|
+
{ prefix: "gemini-3-pro-preview", pricing: GOOGLE_MODEL_PRICING["gemini-3-pro-preview"] },
|
|
221
|
+
{ prefix: "gemini-3-flash-preview", pricing: GOOGLE_MODEL_PRICING["gemini-3-flash-preview"] },
|
|
222
|
+
{ prefix: "gemini-3.1-flash-lite-preview", pricing: GOOGLE_MODEL_PRICING["gemini-3.1-flash-lite-preview"] },
|
|
223
|
+
{ prefix: "gemini-2.5-flash-lite-preview-", pricing: GOOGLE_MODEL_PRICING["gemini-2.5-flash-lite"] },
|
|
224
|
+
{ prefix: "gemini-flash-latest", pricing: GOOGLE_MODEL_PRICING["gemini-2.5-flash"] },
|
|
225
|
+
{ prefix: "gemini-flash-lite-latest", pricing: GOOGLE_MODEL_PRICING["gemini-2.5-flash-lite"] },
|
|
226
|
+
{ prefix: "gemini-pro-latest", pricing: GOOGLE_MODEL_PRICING["gemini-2.5-pro"] },
|
|
227
|
+
{
|
|
228
|
+
prefix: "gemma-4-",
|
|
229
|
+
pricing: { inputPerMillion: 0, outputPerMillion: 0, cachedInputPerMillion: 0 }
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
prefix: "gemma-3-",
|
|
233
|
+
pricing: { inputPerMillion: 0, outputPerMillion: 0, cachedInputPerMillion: 0 }
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
prefix: "gemma-3n-",
|
|
237
|
+
pricing: { inputPerMillion: 0, outputPerMillion: 0, cachedInputPerMillion: 0 }
|
|
238
|
+
}
|
|
239
|
+
];
|
|
240
|
+
var OPENAI_LONG_CONTEXT_THRESHOLD = 272e3;
|
|
241
|
+
var OPENAI_MODEL_PRICING = {
|
|
242
|
+
"gpt-5.5": {
|
|
243
|
+
inputPerMillion: 5,
|
|
244
|
+
cachedInputPerMillion: 0.5,
|
|
245
|
+
outputPerMillion: 30,
|
|
246
|
+
longInputPerMillion: 10,
|
|
247
|
+
longCachedInputPerMillion: 1,
|
|
248
|
+
longOutputPerMillion: 45,
|
|
249
|
+
longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD
|
|
250
|
+
},
|
|
251
|
+
"gpt-5.5-pro": {
|
|
252
|
+
inputPerMillion: 30,
|
|
253
|
+
outputPerMillion: 180,
|
|
254
|
+
longInputPerMillion: 60,
|
|
255
|
+
longOutputPerMillion: 270,
|
|
256
|
+
longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD
|
|
257
|
+
},
|
|
258
|
+
"gpt-5.4": {
|
|
259
|
+
inputPerMillion: 2.5,
|
|
260
|
+
cachedInputPerMillion: 0.25,
|
|
261
|
+
outputPerMillion: 15,
|
|
262
|
+
longInputPerMillion: 5,
|
|
263
|
+
longCachedInputPerMillion: 0.5,
|
|
264
|
+
longOutputPerMillion: 22.5,
|
|
265
|
+
longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD
|
|
266
|
+
},
|
|
267
|
+
"gpt-5.4-mini": { inputPerMillion: 0.75, cachedInputPerMillion: 0.075, outputPerMillion: 4.5 },
|
|
268
|
+
"gpt-5.4-nano": { inputPerMillion: 0.2, cachedInputPerMillion: 0.02, outputPerMillion: 1.25 },
|
|
269
|
+
"gpt-5.4-pro": {
|
|
270
|
+
inputPerMillion: 30,
|
|
271
|
+
outputPerMillion: 180,
|
|
272
|
+
longInputPerMillion: 60,
|
|
273
|
+
longOutputPerMillion: 270,
|
|
274
|
+
longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD
|
|
275
|
+
},
|
|
276
|
+
"gpt-5.2": { inputPerMillion: 1.75, cachedInputPerMillion: 0.175, outputPerMillion: 14 },
|
|
277
|
+
"gpt-5.2-pro": { inputPerMillion: 21, outputPerMillion: 168 },
|
|
278
|
+
"gpt-5.1": { inputPerMillion: 1.25, cachedInputPerMillion: 0.125, outputPerMillion: 10 },
|
|
279
|
+
"gpt-5": { inputPerMillion: 1.25, cachedInputPerMillion: 0.125, outputPerMillion: 10 },
|
|
280
|
+
"gpt-5-mini": { inputPerMillion: 0.25, cachedInputPerMillion: 0.025, outputPerMillion: 2 },
|
|
281
|
+
"gpt-5-nano": { inputPerMillion: 0.05, cachedInputPerMillion: 5e-3, outputPerMillion: 0.4 },
|
|
282
|
+
"gpt-5-pro": { inputPerMillion: 15, outputPerMillion: 120 },
|
|
283
|
+
"gpt-4.1": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 8 },
|
|
284
|
+
"gpt-4.1-mini": { inputPerMillion: 0.4, cachedInputPerMillion: 0.1, outputPerMillion: 1.6 },
|
|
285
|
+
"gpt-4.1-nano": { inputPerMillion: 0.1, cachedInputPerMillion: 0.025, outputPerMillion: 0.4 },
|
|
286
|
+
"gpt-4o": { inputPerMillion: 2.5, cachedInputPerMillion: 1.25, outputPerMillion: 10 },
|
|
287
|
+
"gpt-4o-2024-05-13": { inputPerMillion: 5, outputPerMillion: 15 },
|
|
288
|
+
"gpt-4o-mini": { inputPerMillion: 0.15, cachedInputPerMillion: 0.075, outputPerMillion: 0.6 },
|
|
289
|
+
o1: { inputPerMillion: 15, cachedInputPerMillion: 7.5, outputPerMillion: 60 },
|
|
290
|
+
"o1-pro": { inputPerMillion: 150, outputPerMillion: 600 },
|
|
291
|
+
"o3-pro": { inputPerMillion: 20, outputPerMillion: 80 },
|
|
292
|
+
o3: { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 8 },
|
|
293
|
+
"o4-mini": { inputPerMillion: 1.1, cachedInputPerMillion: 0.275, outputPerMillion: 4.4 },
|
|
294
|
+
"o3-mini": { inputPerMillion: 1.1, cachedInputPerMillion: 0.55, outputPerMillion: 4.4 },
|
|
295
|
+
"o1-mini": { inputPerMillion: 1.1, cachedInputPerMillion: 0.55, outputPerMillion: 4.4 },
|
|
296
|
+
"gpt-4-turbo": { inputPerMillion: 10, outputPerMillion: 30 },
|
|
297
|
+
"gpt-4-turbo-2024-04-09": { inputPerMillion: 10, outputPerMillion: 30 },
|
|
298
|
+
"gpt-4-0125-preview": { inputPerMillion: 10, outputPerMillion: 30 },
|
|
299
|
+
"gpt-4-1106-preview": { inputPerMillion: 10, outputPerMillion: 30 },
|
|
300
|
+
"gpt-4-1106-vision-preview": { inputPerMillion: 10, outputPerMillion: 30 },
|
|
301
|
+
"gpt-4": { inputPerMillion: 30, outputPerMillion: 60 },
|
|
302
|
+
"gpt-4-0613": { inputPerMillion: 30, outputPerMillion: 60 },
|
|
303
|
+
"gpt-4-0314": { inputPerMillion: 30, outputPerMillion: 60 },
|
|
304
|
+
"gpt-4-32k": { inputPerMillion: 60, outputPerMillion: 120 },
|
|
305
|
+
"gpt-3.5-turbo": { inputPerMillion: 0.5, outputPerMillion: 1.5 },
|
|
306
|
+
"gpt-3.5-turbo-0125": { inputPerMillion: 0.5, outputPerMillion: 1.5 },
|
|
307
|
+
"gpt-3.5-turbo-1106": { inputPerMillion: 1, outputPerMillion: 2 },
|
|
308
|
+
"gpt-3.5-turbo-0613": { inputPerMillion: 1.5, outputPerMillion: 2 },
|
|
309
|
+
"gpt-3.5-0301": { inputPerMillion: 1.5, outputPerMillion: 2 },
|
|
310
|
+
"gpt-3.5-turbo-instruct": { inputPerMillion: 1.5, outputPerMillion: 2 },
|
|
311
|
+
"gpt-3.5-turbo-16k-0613": { inputPerMillion: 3, outputPerMillion: 4 },
|
|
312
|
+
"davinci-002": { inputPerMillion: 2, outputPerMillion: 2 },
|
|
313
|
+
"babbage-002": { inputPerMillion: 0.4, outputPerMillion: 0.4 }
|
|
314
|
+
};
|
|
315
|
+
var OPENAI_MODEL_PRICING_PREFIXES = [
|
|
316
|
+
{ prefix: "gpt-5.5-pro", pricing: OPENAI_MODEL_PRICING["gpt-5.5-pro"] },
|
|
317
|
+
{ prefix: "gpt-5.5", pricing: OPENAI_MODEL_PRICING["gpt-5.5"] },
|
|
318
|
+
{ prefix: "gpt-5.4-mini", pricing: OPENAI_MODEL_PRICING["gpt-5.4-mini"] },
|
|
319
|
+
{ prefix: "gpt-5.4-nano", pricing: OPENAI_MODEL_PRICING["gpt-5.4-nano"] },
|
|
320
|
+
{ prefix: "gpt-5.4-pro", pricing: OPENAI_MODEL_PRICING["gpt-5.4-pro"] },
|
|
321
|
+
{ prefix: "gpt-5.4", pricing: OPENAI_MODEL_PRICING["gpt-5.4"] },
|
|
322
|
+
{ prefix: "gpt-5.2-pro", pricing: OPENAI_MODEL_PRICING["gpt-5.2-pro"] },
|
|
323
|
+
{ prefix: "gpt-5.2", pricing: OPENAI_MODEL_PRICING["gpt-5.2"] },
|
|
324
|
+
{ prefix: "gpt-5.1", pricing: OPENAI_MODEL_PRICING["gpt-5.1"] },
|
|
325
|
+
{ prefix: "gpt-5-mini", pricing: OPENAI_MODEL_PRICING["gpt-5-mini"] },
|
|
326
|
+
{ prefix: "gpt-5-nano", pricing: OPENAI_MODEL_PRICING["gpt-5-nano"] },
|
|
327
|
+
{ prefix: "gpt-5-pro", pricing: OPENAI_MODEL_PRICING["gpt-5-pro"] },
|
|
328
|
+
{ prefix: "gpt-5", pricing: OPENAI_MODEL_PRICING["gpt-5"] },
|
|
329
|
+
{ prefix: "gpt-4.1-mini", pricing: OPENAI_MODEL_PRICING["gpt-4.1-mini"] },
|
|
330
|
+
{ prefix: "gpt-4.1-nano", pricing: OPENAI_MODEL_PRICING["gpt-4.1-nano"] },
|
|
331
|
+
{ prefix: "gpt-4.1", pricing: OPENAI_MODEL_PRICING["gpt-4.1"] },
|
|
332
|
+
{ prefix: "gpt-4o-mini", pricing: OPENAI_MODEL_PRICING["gpt-4o-mini"] },
|
|
333
|
+
{ prefix: "gpt-4o", pricing: OPENAI_MODEL_PRICING["gpt-4o"] },
|
|
334
|
+
{ prefix: "o3-pro", pricing: OPENAI_MODEL_PRICING["o3-pro"] },
|
|
335
|
+
{ prefix: "o3-mini", pricing: OPENAI_MODEL_PRICING["o3-mini"] },
|
|
336
|
+
{ prefix: "o4-mini", pricing: OPENAI_MODEL_PRICING["o4-mini"] },
|
|
337
|
+
{ prefix: "o1-pro", pricing: OPENAI_MODEL_PRICING["o1-pro"] },
|
|
338
|
+
{ prefix: "o1-mini", pricing: OPENAI_MODEL_PRICING["o1-mini"] },
|
|
339
|
+
{ prefix: "o3", pricing: OPENAI_MODEL_PRICING.o3 },
|
|
340
|
+
{ prefix: "o1", pricing: OPENAI_MODEL_PRICING.o1 },
|
|
341
|
+
{ prefix: "gpt-4-turbo", pricing: OPENAI_MODEL_PRICING["gpt-4-turbo"] },
|
|
342
|
+
{ prefix: "gpt-4-32k", pricing: OPENAI_MODEL_PRICING["gpt-4-32k"] },
|
|
343
|
+
{ prefix: "gpt-4", pricing: OPENAI_MODEL_PRICING["gpt-4"] },
|
|
344
|
+
{ prefix: "gpt-3.5-turbo", pricing: OPENAI_MODEL_PRICING["gpt-3.5-turbo"] }
|
|
345
|
+
];
|
|
346
|
+
var GROQ_MODEL_PRICING = {
|
|
347
|
+
"llama-3.1-8b-instant": { inputPerMillion: 0.05, outputPerMillion: 0.08 },
|
|
348
|
+
"llama-3.3-70b-versatile": { inputPerMillion: 0.59, outputPerMillion: 0.79 },
|
|
349
|
+
"meta-llama/llama-4-scout-17b-16e-instruct": { inputPerMillion: 0.11, outputPerMillion: 0.34 },
|
|
350
|
+
"moonshotai/kimi-k2-instruct": { inputPerMillion: 1, outputPerMillion: 3 },
|
|
351
|
+
"openai/gpt-oss-120b": { inputPerMillion: 0.15, cachedInputPerMillion: 0.075, outputPerMillion: 0.6 },
|
|
352
|
+
"openai/gpt-oss-20b": { inputPerMillion: 0.075, cachedInputPerMillion: 0.037, outputPerMillion: 0.3 },
|
|
353
|
+
"qwen/qwen3-32b": { inputPerMillion: 0.29, outputPerMillion: 0.59 }
|
|
354
|
+
};
|
|
355
|
+
var XAI_MODEL_PRICING = {
|
|
356
|
+
"grok-4-0709": { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },
|
|
357
|
+
"grok-4": { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },
|
|
358
|
+
"grok-4-latest": { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },
|
|
359
|
+
"grok-4-fast-reasoning": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },
|
|
360
|
+
"grok-4-fast-non-reasoning": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },
|
|
361
|
+
"grok-4-1-fast-reasoning": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },
|
|
362
|
+
"grok-4-1-fast-non-reasoning": { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },
|
|
363
|
+
"grok-4.20-0309-reasoning": { inputPerMillion: 20, cachedInputPerMillion: 2, outputPerMillion: 60 },
|
|
364
|
+
"grok-4.20-0309-non-reasoning": { inputPerMillion: 20, cachedInputPerMillion: 2, outputPerMillion: 60 },
|
|
365
|
+
"grok-4.20-multi-agent-0309": { inputPerMillion: 20, cachedInputPerMillion: 2, outputPerMillion: 60 },
|
|
366
|
+
"grok-code-fast-1": { inputPerMillion: 2, cachedInputPerMillion: 0.2, outputPerMillion: 15 },
|
|
367
|
+
"grok-3": { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },
|
|
368
|
+
"grok-3-latest": { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },
|
|
369
|
+
"grok-3-mini": { inputPerMillion: 3, cachedInputPerMillion: 0.75, outputPerMillion: 5 },
|
|
370
|
+
"grok-3-mini-latest": { inputPerMillion: 3, cachedInputPerMillion: 0.75, outputPerMillion: 5 }
|
|
371
|
+
};
|
|
372
|
+
var CLOUDFLARE_MODEL_PRICING = {
|
|
373
|
+
"@cf/meta/llama-3.2-1b-instruct": { inputPerMillion: 0.027, outputPerMillion: 0.201 },
|
|
374
|
+
"@cf/meta/llama-3.2-3b-instruct": { inputPerMillion: 0.051, outputPerMillion: 0.335 },
|
|
375
|
+
"@cf/meta/llama-3.1-8b-instruct-fp8-fast": { inputPerMillion: 0.045, outputPerMillion: 0.384 },
|
|
376
|
+
"@cf/meta/llama-3.2-11b-vision-instruct": { inputPerMillion: 0.049, outputPerMillion: 0.676 },
|
|
377
|
+
"@cf/meta/llama-3.1-70b-instruct-fp8-fast": { inputPerMillion: 0.293, outputPerMillion: 2.253 },
|
|
378
|
+
"@cf/meta/llama-3.3-70b-instruct-fp8-fast": { inputPerMillion: 0.293, outputPerMillion: 2.253 },
|
|
379
|
+
"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": { inputPerMillion: 0.497, outputPerMillion: 4.881 },
|
|
380
|
+
"@cf/mistral/mistral-7b-instruct-v0.1": { inputPerMillion: 0.11, outputPerMillion: 0.19 },
|
|
381
|
+
"@cf/mistralai/mistral-small-3.1-24b-instruct": { inputPerMillion: 0.351, outputPerMillion: 0.555 },
|
|
382
|
+
"@cf/meta/llama-3.1-8b-instruct": { inputPerMillion: 0.282, outputPerMillion: 0.827 },
|
|
383
|
+
"@cf/meta/llama-3.1-8b-instruct-fp8": { inputPerMillion: 0.152, outputPerMillion: 0.287 },
|
|
384
|
+
"@cf/meta/llama-3.1-8b-instruct-awq": { inputPerMillion: 0.123, outputPerMillion: 0.266 },
|
|
385
|
+
"@cf/meta/llama-3-8b-instruct": { inputPerMillion: 0.282, outputPerMillion: 0.827 },
|
|
386
|
+
"@cf/meta/llama-3-8b-instruct-awq": { inputPerMillion: 0.123, outputPerMillion: 0.266 },
|
|
387
|
+
"@cf/meta/llama-2-7b-chat-fp16": { inputPerMillion: 0.556, outputPerMillion: 6.667 },
|
|
388
|
+
"@cf/meta/llama-guard-3-8b": { inputPerMillion: 0.484, outputPerMillion: 0.03 },
|
|
389
|
+
"@cf/meta/llama-4-scout-17b-16e-instruct": { inputPerMillion: 0.27, outputPerMillion: 0.85 },
|
|
390
|
+
"@cf/google/gemma-3-12b-it": { inputPerMillion: 0.345, outputPerMillion: 0.556 },
|
|
391
|
+
"@cf/qwen/qwq-32b": { inputPerMillion: 0.66, outputPerMillion: 1 },
|
|
392
|
+
"@cf/qwen/qwen2.5-coder-32b-instruct": { inputPerMillion: 0.66, outputPerMillion: 1 },
|
|
393
|
+
"@cf/qwen/qwen3-30b-a3b-fp8": { inputPerMillion: 0.051, outputPerMillion: 0.335 },
|
|
394
|
+
"@cf/openai/gpt-oss-120b": { inputPerMillion: 0.35, outputPerMillion: 0.75 },
|
|
395
|
+
"@cf/openai/gpt-oss-20b": { inputPerMillion: 0.2, outputPerMillion: 0.3 },
|
|
396
|
+
"@cf/aisingapore/gemma-sea-lion-v4-27b-it": { inputPerMillion: 0.351, outputPerMillion: 0.555 },
|
|
397
|
+
"@cf/ibm-granite/granite-4.0-h-micro": { inputPerMillion: 0.017, outputPerMillion: 0.112 },
|
|
398
|
+
"@cf/zai-org/glm-4.7-flash": { inputPerMillion: 0.06, outputPerMillion: 0.4 },
|
|
399
|
+
"@cf/nvidia/nemotron-3-120b-a12b": { inputPerMillion: 0.5, outputPerMillion: 1.5 },
|
|
400
|
+
"@cf/moonshotai/kimi-k2.5": { inputPerMillion: 0.6, cachedInputPerMillion: 0.1, outputPerMillion: 3 }
|
|
401
|
+
};
|
|
402
|
+
function normalizeModelId(modelId) {
|
|
403
|
+
return (modelId || "").trim().toLowerCase();
|
|
404
|
+
}
|
|
405
|
+
function normalizeOpenAIModelId(modelId) {
|
|
406
|
+
return normalizeModelId(modelId).replace(/^openai\//, "");
|
|
407
|
+
}
|
|
408
|
+
function normalizeGoogleModelId(modelId) {
|
|
409
|
+
return normalizeModelId(modelId).replace(/^google\//, "").replace(/^models\//, "").replace(/^publishers\/google\/models\//, "");
|
|
410
|
+
}
|
|
411
|
+
function normalizeCloudflareModelId(modelId) {
|
|
412
|
+
const trimmed = (modelId || "").trim();
|
|
413
|
+
if (trimmed.startsWith("@cf/")) return trimmed;
|
|
414
|
+
return `@cf/${trimmed.replace(/^@cf\//, "")}`;
|
|
415
|
+
}
|
|
416
|
+
function roundCost(value) {
|
|
417
|
+
return Number(value.toFixed(12));
|
|
418
|
+
}
|
|
419
|
+
function normalizeModality(modality) {
|
|
420
|
+
const normalized = (modality || "").trim().toLowerCase();
|
|
421
|
+
if (normalized === "text") return "text";
|
|
422
|
+
if (normalized === "image") return "image";
|
|
423
|
+
if (normalized === "video") return "video";
|
|
424
|
+
if (normalized === "audio") return "audio";
|
|
425
|
+
if (normalized === "document") return "document";
|
|
426
|
+
return "unspecified";
|
|
427
|
+
}
|
|
428
|
+
function toModalityCounts(details) {
|
|
429
|
+
const counts = {};
|
|
430
|
+
for (const detail of details || []) {
|
|
431
|
+
const modality = normalizeModality(detail.modality);
|
|
432
|
+
const tokenCount = Math.max(detail.tokenCount ?? 0, 0);
|
|
433
|
+
counts[modality] = (counts[modality] ?? 0) + tokenCount;
|
|
434
|
+
}
|
|
435
|
+
return counts;
|
|
436
|
+
}
|
|
437
|
+
function sumModalityCosts(counts, modalityRates, defaultRate) {
|
|
438
|
+
let total = 0;
|
|
439
|
+
for (const [modality, tokenCount] of Object.entries(counts)) {
|
|
440
|
+
if (!tokenCount) continue;
|
|
441
|
+
const rate = modalityRates?.[modality] ?? defaultRate;
|
|
442
|
+
total += tokenCount / TOKENS_PER_MILLION * rate;
|
|
443
|
+
}
|
|
444
|
+
return total;
|
|
445
|
+
}
|
|
446
|
+
function sumModalityCostNumerator(counts, modalityRates, defaultRate) {
|
|
447
|
+
let total = 0;
|
|
448
|
+
for (const [modality, tokenCount] of Object.entries(counts)) {
|
|
449
|
+
if (!tokenCount) continue;
|
|
450
|
+
const rate = modalityRates?.[modality] ?? defaultRate;
|
|
451
|
+
total += tokenCount * ratePerMillionMicrocents(rate);
|
|
452
|
+
}
|
|
453
|
+
return total;
|
|
454
|
+
}
|
|
455
|
+
function ratePerMillionMicrocents(usdPerMillion, multiplier = 1) {
|
|
456
|
+
return Math.round(usdPerMillion * multiplier * MICROCENTS_PER_DOLLAR);
|
|
457
|
+
}
|
|
458
|
+
function ceilDiv(numerator, divisor) {
|
|
459
|
+
return Math.ceil(numerator / divisor);
|
|
460
|
+
}
|
|
461
|
+
function getAnthropicModelPricing(modelId) {
|
|
462
|
+
const normalized = normalizeModelId(modelId);
|
|
463
|
+
let best = null;
|
|
464
|
+
for (const [prefix, pricing] of ANTHROPIC_MODEL_PRICING) {
|
|
465
|
+
if (normalized.startsWith(prefix) && (!best || prefix.length > best.prefix.length)) {
|
|
466
|
+
best = { prefix, pricing };
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return best ? { ...best.pricing } : null;
|
|
470
|
+
}
|
|
471
|
+
function calculateAnthropicUsageCost(modelId, buckets) {
|
|
472
|
+
const pricing = getAnthropicModelPricing(modelId);
|
|
473
|
+
if (!pricing) return void 0;
|
|
474
|
+
const inputRate = pricing.inputPerMillion / TOKENS_PER_MILLION;
|
|
475
|
+
const outputRate = pricing.outputPerMillion / TOKENS_PER_MILLION;
|
|
476
|
+
return roundCost(
|
|
477
|
+
buckets.inputTokens * inputRate + buckets.cacheWrite5mTokens * inputRate * 1.25 + buckets.cacheWrite1hTokens * inputRate * 2 + buckets.cacheReadTokens * inputRate * 0.1 + buckets.outputTokens * outputRate
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
function getCerebrasModelPricing(modelId) {
|
|
481
|
+
const pricing = CEREBRAS_MODEL_PRICING[normalizeModelId(modelId)];
|
|
482
|
+
return pricing ? { ...pricing } : void 0;
|
|
483
|
+
}
|
|
484
|
+
function calculateCerebrasUsageCost(modelId, usage) {
|
|
485
|
+
const pricing = getCerebrasModelPricing(modelId);
|
|
486
|
+
if (!pricing) return void 0;
|
|
487
|
+
return roundCost(
|
|
488
|
+
(usage.promptTokens * pricing.inputPerMillion + usage.completionTokens * pricing.outputPerMillion) / TOKENS_PER_MILLION
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
function getGoogleModelPricing(modelId) {
|
|
492
|
+
const normalizedModelId = normalizeGoogleModelId(modelId);
|
|
493
|
+
const exact = GOOGLE_MODEL_PRICING[normalizedModelId];
|
|
494
|
+
if (exact) return { ...exact };
|
|
495
|
+
const prefix = GOOGLE_MODEL_PRICING_PREFIXES.find((entry) => normalizedModelId.startsWith(entry.prefix));
|
|
496
|
+
return prefix ? { ...prefix.pricing } : void 0;
|
|
497
|
+
}
|
|
498
|
+
function calculateGoogleUsageCost(modelId, usage, imageCount = 0) {
|
|
499
|
+
const pricing = getGoogleModelPricing(modelId);
|
|
500
|
+
if (!pricing) return void 0;
|
|
501
|
+
const cachedTokens = usage.cachedTokens ?? 0;
|
|
502
|
+
const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);
|
|
503
|
+
const useLongContext = pricing.longContextThreshold != null && usage.promptTokens > pricing.longContextThreshold;
|
|
504
|
+
const inputRate = useLongContext ? pricing.longInputPerMillion ?? pricing.inputPerMillion : pricing.inputPerMillion;
|
|
505
|
+
const outputRate = useLongContext ? pricing.longOutputPerMillion ?? pricing.outputPerMillion ?? 0 : pricing.outputPerMillion ?? 0;
|
|
506
|
+
const cachedRate = useLongContext ? pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? 0 : pricing.cachedInputPerMillion ?? 0;
|
|
507
|
+
const billableOutputTokens = usage.completionTokens + (usage.reasoningTokens ?? 0);
|
|
508
|
+
const promptModalityCounts = toModalityCounts(usage.promptTokenDetails);
|
|
509
|
+
const cachedModalityCounts = toModalityCounts(usage.cachedTokenDetails);
|
|
510
|
+
const uncachedPromptModalityCounts = {};
|
|
511
|
+
for (const modality of /* @__PURE__ */ new Set([
|
|
512
|
+
...Object.keys(promptModalityCounts),
|
|
513
|
+
...Object.keys(cachedModalityCounts)
|
|
514
|
+
])) {
|
|
515
|
+
uncachedPromptModalityCounts[modality] = Math.max(
|
|
516
|
+
(promptModalityCounts[modality] ?? 0) - (cachedModalityCounts[modality] ?? 0),
|
|
517
|
+
0
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
const completionModalityCounts = toModalityCounts(usage.completionTokenDetails);
|
|
521
|
+
if (usage.reasoningTokens) {
|
|
522
|
+
completionModalityCounts.text = (completionModalityCounts.text ?? 0) + usage.reasoningTokens;
|
|
523
|
+
}
|
|
524
|
+
const hasPromptModalityPricing = Object.keys(uncachedPromptModalityCounts).length > 0 && pricing.inputByModalityPerMillion;
|
|
525
|
+
const hasCachedModalityPricing = Object.keys(cachedModalityCounts).length > 0 && pricing.cachedByModalityPerMillion;
|
|
526
|
+
const hasOutputModalityPricing = Object.keys(completionModalityCounts).length > 0 && pricing.outputByModalityPerMillion;
|
|
527
|
+
const inputCost = hasPromptModalityPricing ? sumModalityCosts(uncachedPromptModalityCounts, pricing.inputByModalityPerMillion, inputRate) : uncachedPromptTokens / TOKENS_PER_MILLION * inputRate;
|
|
528
|
+
const cachedCost = hasCachedModalityPricing ? sumModalityCosts(cachedModalityCounts, pricing.cachedByModalityPerMillion, cachedRate) : cachedTokens / TOKENS_PER_MILLION * cachedRate;
|
|
529
|
+
const outputCost = hasOutputModalityPricing ? sumModalityCosts(completionModalityCounts, pricing.outputByModalityPerMillion, outputRate) : billableOutputTokens / TOKENS_PER_MILLION * outputRate;
|
|
530
|
+
const imageCost = imageCount * (pricing.outputImagePerImage ?? 0);
|
|
531
|
+
return roundCost(inputCost + cachedCost + outputCost + imageCost);
|
|
532
|
+
}
|
|
533
|
+
function getOpenAIModelPricing(modelId) {
|
|
534
|
+
const normalizedModelId = normalizeOpenAIModelId(modelId);
|
|
535
|
+
const exact = OPENAI_MODEL_PRICING[normalizedModelId];
|
|
536
|
+
if (exact) return { ...exact };
|
|
537
|
+
const prefix = OPENAI_MODEL_PRICING_PREFIXES.find((entry) => normalizedModelId.startsWith(entry.prefix));
|
|
538
|
+
return prefix ? { ...prefix.pricing } : void 0;
|
|
539
|
+
}
|
|
540
|
+
function calculateOpenAIUsageCost(modelId, usage) {
|
|
541
|
+
const pricing = getOpenAIModelPricing(modelId);
|
|
542
|
+
if (!pricing) return void 0;
|
|
543
|
+
const cachedTokens = usage.cachedTokens ?? 0;
|
|
544
|
+
const promptTokens = Math.max(usage.promptTokens, 0);
|
|
545
|
+
const uncachedPromptTokens = Math.max(0, promptTokens - cachedTokens);
|
|
546
|
+
const useLongContext = pricing.longContextThreshold != null && promptTokens >= pricing.longContextThreshold;
|
|
547
|
+
const inputRate = useLongContext ? pricing.longInputPerMillion ?? pricing.inputPerMillion : pricing.inputPerMillion;
|
|
548
|
+
const outputRate = useLongContext ? pricing.longOutputPerMillion ?? pricing.outputPerMillion : pricing.outputPerMillion;
|
|
549
|
+
const cachedRate = useLongContext ? pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? pricing.inputPerMillion : pricing.cachedInputPerMillion ?? pricing.inputPerMillion;
|
|
550
|
+
const inputCost = uncachedPromptTokens / TOKENS_PER_MILLION * inputRate;
|
|
551
|
+
const cachedCost = cachedTokens / TOKENS_PER_MILLION * cachedRate;
|
|
552
|
+
const outputCost = Math.max(usage.completionTokens, 0) / TOKENS_PER_MILLION * outputRate;
|
|
553
|
+
return roundCost(inputCost + cachedCost + outputCost);
|
|
554
|
+
}
|
|
555
|
+
function getGroqModelPricing(modelId) {
|
|
556
|
+
const pricing = GROQ_MODEL_PRICING[normalizeModelId(modelId)];
|
|
557
|
+
return pricing ? { ...pricing } : void 0;
|
|
558
|
+
}
|
|
559
|
+
function calculateGroqUsageCost(modelId, usage) {
|
|
560
|
+
const pricing = getGroqModelPricing(modelId);
|
|
561
|
+
if (!pricing) return void 0;
|
|
562
|
+
const cachedTokens = usage.cachedTokens ?? 0;
|
|
563
|
+
const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);
|
|
564
|
+
const inputCost = uncachedPromptTokens / TOKENS_PER_MILLION * pricing.inputPerMillion;
|
|
565
|
+
const cachedInputCost = pricing.cachedInputPerMillion ? cachedTokens / TOKENS_PER_MILLION * pricing.cachedInputPerMillion : 0;
|
|
566
|
+
const outputCost = usage.completionTokens / TOKENS_PER_MILLION * pricing.outputPerMillion;
|
|
567
|
+
return roundCost(inputCost + cachedInputCost + outputCost);
|
|
568
|
+
}
|
|
569
|
+
function getXAITextPricing(modelId) {
|
|
570
|
+
const pricing = XAI_MODEL_PRICING[normalizeModelId(modelId)];
|
|
571
|
+
return pricing ? { ...pricing } : void 0;
|
|
572
|
+
}
|
|
573
|
+
function calculateXAIUsageCost(modelId, usage) {
|
|
574
|
+
const pricing = getXAITextPricing(modelId);
|
|
575
|
+
if (!pricing) return void 0;
|
|
576
|
+
const cachedTokens = usage.cachedTokens ?? 0;
|
|
577
|
+
const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);
|
|
578
|
+
const inputCost = uncachedPromptTokens / TOKENS_PER_MILLION * pricing.inputPerMillion;
|
|
579
|
+
const cachedCost = pricing.cachedInputPerMillion ? cachedTokens / TOKENS_PER_MILLION * pricing.cachedInputPerMillion : 0;
|
|
580
|
+
const outputCost = usage.completionTokens / TOKENS_PER_MILLION * pricing.outputPerMillion;
|
|
581
|
+
return roundCost(inputCost + cachedCost + outputCost);
|
|
582
|
+
}
|
|
583
|
+
function ticksToUsd(ticks) {
|
|
584
|
+
if (typeof ticks !== "number") return void 0;
|
|
585
|
+
return roundCost(ticks / XAI_TICKS_PER_DOLLAR);
|
|
586
|
+
}
|
|
587
|
+
function getCloudflareModelPricing(modelId) {
|
|
588
|
+
const pricing = CLOUDFLARE_MODEL_PRICING[normalizeCloudflareModelId(modelId)];
|
|
589
|
+
return pricing ? { ...pricing } : void 0;
|
|
590
|
+
}
|
|
591
|
+
function calculateCloudflareUsageCost(modelId, usage) {
|
|
592
|
+
const pricing = getCloudflareModelPricing(modelId);
|
|
593
|
+
if (!pricing) return void 0;
|
|
594
|
+
const cachedTokens = usage.cachedTokens ?? 0;
|
|
595
|
+
const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);
|
|
596
|
+
const inputCost = uncachedPromptTokens / TOKENS_PER_MILLION * pricing.inputPerMillion;
|
|
597
|
+
const cachedInputCost = pricing.cachedInputPerMillion ? cachedTokens / TOKENS_PER_MILLION * pricing.cachedInputPerMillion : 0;
|
|
598
|
+
const outputCost = usage.completionTokens / TOKENS_PER_MILLION * pricing.outputPerMillion;
|
|
599
|
+
return roundCost(inputCost + cachedInputCost + outputCost);
|
|
600
|
+
}
|
|
601
|
+
function getProviderModelPricing(provider, modelId) {
|
|
602
|
+
if (provider === "anthropic") {
|
|
603
|
+
const pricing = getAnthropicModelPricing(modelId);
|
|
604
|
+
return pricing ? {
|
|
605
|
+
inputPerMillion: pricing.inputPerMillion,
|
|
606
|
+
outputPerMillion: pricing.outputPerMillion,
|
|
607
|
+
cachedInputPerMillion: roundCost(pricing.inputPerMillion * 0.1),
|
|
608
|
+
source: "anthropic-static"
|
|
609
|
+
} : void 0;
|
|
610
|
+
}
|
|
611
|
+
if (provider === "cerebras") {
|
|
612
|
+
const pricing = getCerebrasModelPricing(modelId);
|
|
613
|
+
return pricing ? { ...pricing, source: "cerebras-static" } : void 0;
|
|
614
|
+
}
|
|
615
|
+
if (provider === "google") {
|
|
616
|
+
const pricing = getGoogleModelPricing(modelId || "");
|
|
617
|
+
return pricing ? {
|
|
618
|
+
inputPerMillion: pricing.inputPerMillion,
|
|
619
|
+
outputPerMillion: pricing.outputPerMillion ?? 0,
|
|
620
|
+
cachedInputPerMillion: pricing.cachedInputPerMillion,
|
|
621
|
+
longInputPerMillion: pricing.longInputPerMillion,
|
|
622
|
+
longOutputPerMillion: pricing.longOutputPerMillion,
|
|
623
|
+
longCachedInputPerMillion: pricing.longCachedInputPerMillion,
|
|
624
|
+
longContextThreshold: pricing.longContextThreshold,
|
|
625
|
+
source: "google-static"
|
|
626
|
+
} : void 0;
|
|
627
|
+
}
|
|
628
|
+
if (provider === "groq") {
|
|
629
|
+
const pricing = getGroqModelPricing(modelId || "");
|
|
630
|
+
return pricing ? { ...pricing, source: "groq-static" } : void 0;
|
|
631
|
+
}
|
|
632
|
+
if (provider === "openai") {
|
|
633
|
+
const pricing = getOpenAIModelPricing(modelId || "");
|
|
634
|
+
return pricing ? { ...pricing, source: "openai-static" } : void 0;
|
|
635
|
+
}
|
|
636
|
+
if (provider === "xai") {
|
|
637
|
+
const pricing = getXAITextPricing(modelId || "");
|
|
638
|
+
return pricing ? { ...pricing, source: "xai-static" } : void 0;
|
|
639
|
+
}
|
|
640
|
+
if (provider === "cloudflare") {
|
|
641
|
+
const pricing = getCloudflareModelPricing(modelId || "");
|
|
642
|
+
return pricing ? { ...pricing, source: "cloudflare-static" } : void 0;
|
|
643
|
+
}
|
|
644
|
+
return void 0;
|
|
645
|
+
}
|
|
646
|
+
function costFromStandardBuckets(usage, pricing, options = {}) {
|
|
647
|
+
const cachedTokens = Math.max(usage.cached_tokens ?? 0, 0);
|
|
648
|
+
const inputTokens = Math.max(usage.input_tokens, 0);
|
|
649
|
+
const uncachedInputTokens = Math.max(inputTokens - cachedTokens, 0);
|
|
650
|
+
const outputTokens = Math.max(usage.output_tokens, 0);
|
|
651
|
+
const reasoningTokens = options.billReasoningAsOutput ? Math.max(usage.reasoning_tokens ?? 0, 0) : 0;
|
|
652
|
+
const useLongContext = pricing.longContextThreshold != null && inputTokens >= pricing.longContextThreshold;
|
|
653
|
+
const inputRate = useLongContext ? pricing.longInputPerMillion ?? pricing.inputPerMillion : pricing.inputPerMillion;
|
|
654
|
+
const outputRate = useLongContext ? pricing.longOutputPerMillion ?? pricing.outputPerMillion : pricing.outputPerMillion;
|
|
655
|
+
const cachedRate = useLongContext ? pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? pricing.inputPerMillion : pricing.cachedInputPerMillion ?? pricing.inputPerMillion;
|
|
656
|
+
return ceilDiv(
|
|
657
|
+
uncachedInputTokens * ratePerMillionMicrocents(inputRate) + cachedTokens * ratePerMillionMicrocents(cachedRate) + (outputTokens + reasoningTokens) * ratePerMillionMicrocents(outputRate),
|
|
658
|
+
TOKENS_PER_MILLION
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
function costFromAnthropicBuckets(usage, pricing) {
|
|
662
|
+
const cacheCreationTokens = Math.max(usage.cache_creation_input_tokens ?? 0, 0);
|
|
663
|
+
const cacheReadTokens = Math.max(usage.cache_read_input_tokens ?? 0, 0);
|
|
664
|
+
const cacheWrite1hTokens = Math.max(usage.cache_creation_1h_input_tokens ?? 0, 0);
|
|
665
|
+
const cacheWrite5mTokens = Math.max(
|
|
666
|
+
usage.cache_creation_5m_input_tokens ?? cacheCreationTokens - cacheWrite1hTokens,
|
|
667
|
+
0
|
|
668
|
+
);
|
|
669
|
+
const uncachedInputTokens = Math.max(usage.input_tokens - cacheCreationTokens - cacheReadTokens, 0);
|
|
670
|
+
return ceilDiv(
|
|
671
|
+
uncachedInputTokens * ratePerMillionMicrocents(pricing.inputPerMillion) + cacheWrite5mTokens * ratePerMillionMicrocents(pricing.inputPerMillion, 1.25) + cacheWrite1hTokens * ratePerMillionMicrocents(pricing.inputPerMillion, 2) + cacheReadTokens * ratePerMillionMicrocents(pricing.inputPerMillion, 0.1) + Math.max(usage.output_tokens, 0) * ratePerMillionMicrocents(pricing.outputPerMillion),
|
|
672
|
+
TOKENS_PER_MILLION
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
function costFromGoogleBuckets(usage, pricing) {
|
|
676
|
+
const cachedTokens = Math.max(usage.cached_tokens ?? 0, 0);
|
|
677
|
+
const inputTokens = Math.max(usage.input_tokens, 0);
|
|
678
|
+
const outputTokens = Math.max(usage.output_tokens, 0);
|
|
679
|
+
const reasoningTokens = Math.max(usage.reasoning_tokens ?? 0, 0);
|
|
680
|
+
const uncachedInputTokens = Math.max(inputTokens - cachedTokens, 0);
|
|
681
|
+
const useLongContext = pricing.longContextThreshold != null && inputTokens > pricing.longContextThreshold;
|
|
682
|
+
const inputRate = useLongContext ? pricing.longInputPerMillion ?? pricing.inputPerMillion : pricing.inputPerMillion;
|
|
683
|
+
const outputRate = useLongContext ? pricing.longOutputPerMillion ?? pricing.outputPerMillion ?? 0 : pricing.outputPerMillion ?? 0;
|
|
684
|
+
const cachedRate = useLongContext ? pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? 0 : pricing.cachedInputPerMillion ?? 0;
|
|
685
|
+
const promptModalityCounts = toModalityCounts(usage.prompt_token_details);
|
|
686
|
+
const cachedModalityCounts = toModalityCounts(usage.cached_token_details);
|
|
687
|
+
const uncachedPromptModalityCounts = {};
|
|
688
|
+
for (const modality of /* @__PURE__ */ new Set([
|
|
689
|
+
...Object.keys(promptModalityCounts),
|
|
690
|
+
...Object.keys(cachedModalityCounts)
|
|
691
|
+
])) {
|
|
692
|
+
uncachedPromptModalityCounts[modality] = Math.max(
|
|
693
|
+
(promptModalityCounts[modality] ?? 0) - (cachedModalityCounts[modality] ?? 0),
|
|
694
|
+
0
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
const completionModalityCounts = toModalityCounts(usage.completion_token_details);
|
|
698
|
+
if (reasoningTokens) {
|
|
699
|
+
completionModalityCounts.text = (completionModalityCounts.text ?? 0) + reasoningTokens;
|
|
700
|
+
}
|
|
701
|
+
const hasPromptModalityPricing = Object.keys(uncachedPromptModalityCounts).length > 0 && pricing.inputByModalityPerMillion;
|
|
702
|
+
const hasCachedModalityPricing = Object.keys(cachedModalityCounts).length > 0 && pricing.cachedByModalityPerMillion;
|
|
703
|
+
const hasOutputModalityPricing = Object.keys(completionModalityCounts).length > 0 && pricing.outputByModalityPerMillion;
|
|
704
|
+
const tokenNumerator = (hasPromptModalityPricing ? sumModalityCostNumerator(uncachedPromptModalityCounts, pricing.inputByModalityPerMillion, inputRate) : uncachedInputTokens * ratePerMillionMicrocents(inputRate)) + (hasCachedModalityPricing ? sumModalityCostNumerator(cachedModalityCounts, pricing.cachedByModalityPerMillion, cachedRate) : cachedTokens * ratePerMillionMicrocents(cachedRate)) + (hasOutputModalityPricing ? sumModalityCostNumerator(completionModalityCounts, pricing.outputByModalityPerMillion, outputRate) : (outputTokens + reasoningTokens) * ratePerMillionMicrocents(outputRate));
|
|
705
|
+
const imageMicrocents = Math.max(usage.image_count ?? 0, 0) * Math.round((pricing.outputImagePerImage ?? 0) * MICROCENTS_PER_DOLLAR);
|
|
706
|
+
return ceilDiv(tokenNumerator, TOKENS_PER_MILLION) + imageMicrocents;
|
|
707
|
+
}
|
|
708
|
+
function calculateProviderUsageCostMicrocents(provider, modelId, usage) {
|
|
709
|
+
const pricing = getProviderModelPricing(provider, modelId);
|
|
710
|
+
if (!pricing) return void 0;
|
|
711
|
+
if (provider === "anthropic") {
|
|
712
|
+
return costFromAnthropicBuckets(usage, pricing);
|
|
713
|
+
}
|
|
714
|
+
if (provider === "google") {
|
|
715
|
+
const googlePricing = getGoogleModelPricing(modelId);
|
|
716
|
+
return googlePricing ? costFromGoogleBuckets(usage, googlePricing) : void 0;
|
|
717
|
+
}
|
|
718
|
+
return costFromStandardBuckets(usage, pricing, {
|
|
719
|
+
billReasoningAsOutput: false
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
export {
|
|
723
|
+
MICROCENTS_PER_DOLLAR,
|
|
724
|
+
calculateAnthropicUsageCost,
|
|
725
|
+
calculateCerebrasUsageCost,
|
|
726
|
+
calculateCloudflareUsageCost,
|
|
727
|
+
calculateGoogleUsageCost,
|
|
728
|
+
calculateGroqUsageCost,
|
|
729
|
+
calculateOpenAIUsageCost,
|
|
730
|
+
calculateProviderUsageCostMicrocents,
|
|
731
|
+
calculateXAIUsageCost,
|
|
732
|
+
getAnthropicModelPricing,
|
|
733
|
+
getCerebrasModelPricing,
|
|
734
|
+
getCloudflareModelPricing,
|
|
735
|
+
getGoogleModelPricing,
|
|
736
|
+
getGroqModelPricing,
|
|
737
|
+
getOpenAIModelPricing,
|
|
738
|
+
getProviderModelPricing,
|
|
739
|
+
getXAITextPricing,
|
|
740
|
+
ticksToUsd
|
|
741
|
+
};
|
|
742
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["const TOKENS_PER_MILLION = 1_000_000;\nexport const MICROCENTS_PER_DOLLAR = 100_000_000;\nconst XAI_TICKS_PER_DOLLAR = 10_000_000_000;\n\nexport type ProviderPricingName =\n | 'anthropic'\n | 'cerebras'\n | 'cloudflare'\n | 'google'\n | 'groq'\n | 'openai'\n | 'xai';\n\nexport interface ProviderUsageLike {\n promptTokens: number;\n completionTokens: number;\n cachedTokens?: number;\n reasoningTokens?: number;\n}\n\nexport interface PlatformTokenUsageLike {\n input_tokens: number;\n output_tokens: number;\n cached_tokens?: number;\n reasoning_tokens?: number;\n prompt_token_details?: GoogleModalityTokenCount[];\n completion_token_details?: GoogleModalityTokenCount[];\n cached_token_details?: GoogleModalityTokenCount[];\n image_count?: number;\n cache_creation_input_tokens?: number;\n cache_creation_5m_input_tokens?: number;\n cache_creation_1h_input_tokens?: number;\n cache_read_input_tokens?: number;\n}\n\nexport interface ProviderModelPricing {\n inputPerMillion: number;\n outputPerMillion: number;\n cachedInputPerMillion?: number;\n longInputPerMillion?: number;\n longOutputPerMillion?: number;\n longCachedInputPerMillion?: number;\n longContextThreshold?: number;\n maxTokens?: number;\n source: `${ProviderPricingName}-static`;\n}\n\nexport interface AnthropicModelPricing {\n inputPerMillion: number;\n outputPerMillion: number;\n}\n\nexport interface AnthropicUsageBuckets {\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWrite5mTokens: number;\n cacheWrite1hTokens: number;\n}\n\nconst ANTHROPIC_MODEL_PRICING: Array<[prefix: string, pricing: AnthropicModelPricing]> = [\n ['claude-fable-5', { inputPerMillion: 10, outputPerMillion: 50 }],\n ['claude-mythos', { inputPerMillion: 10, outputPerMillion: 50 }],\n ['claude-opus-4-8', { inputPerMillion: 5, outputPerMillion: 25 }],\n ['claude-opus-4-7', { inputPerMillion: 5, outputPerMillion: 25 }],\n ['claude-opus-4-6', { inputPerMillion: 5, outputPerMillion: 25 }],\n ['claude-opus-4-5', { inputPerMillion: 5, outputPerMillion: 25 }],\n ['claude-opus-4-1', { inputPerMillion: 15, outputPerMillion: 75 }],\n ['claude-opus-4', { inputPerMillion: 15, outputPerMillion: 75 }],\n ['claude-sonnet-4-6', { inputPerMillion: 3, outputPerMillion: 15 }],\n ['claude-sonnet-4-5', { inputPerMillion: 3, outputPerMillion: 15 }],\n ['claude-sonnet-4', { inputPerMillion: 3, outputPerMillion: 15 }],\n ['claude-haiku-4-5', { inputPerMillion: 1, outputPerMillion: 5 }],\n ['claude-3-7-sonnet', { inputPerMillion: 3, outputPerMillion: 15 }],\n ['claude-3-5-sonnet', { inputPerMillion: 3, outputPerMillion: 15 }],\n ['claude-3-5-haiku', { inputPerMillion: 0.8, outputPerMillion: 4 }],\n ['claude-3-opus', { inputPerMillion: 15, outputPerMillion: 75 }],\n ['claude-3-haiku', { inputPerMillion: 0.25, outputPerMillion: 1.25 }],\n];\n\nexport interface CerebrasModelPricing {\n inputPerMillion: number;\n outputPerMillion: number;\n maxTokens?: number;\n}\n\nconst CEREBRAS_MODEL_PRICING: Record<string, CerebrasModelPricing> = {\n 'zai-glm-4.7': { inputPerMillion: 2.25, outputPerMillion: 2.75, maxTokens: 64_000 },\n 'gpt-oss-120b': { inputPerMillion: 0.35, outputPerMillion: 0.75, maxTokens: 64_000 },\n 'llama3.1-8b': { inputPerMillion: 0.1, outputPerMillion: 0.1, maxTokens: 8_192 },\n 'qwen-3-235b-a22b-instruct-2507': { inputPerMillion: 0.6, outputPerMillion: 1.2, maxTokens: 40_960 },\n 'gemma-4-31b': { inputPerMillion: 0.99, outputPerMillion: 1.49, maxTokens: 4_096 },\n};\n\ntype GooglePricingModality = 'text' | 'image' | 'video' | 'audio' | 'document' | 'unspecified';\n\nexport interface GoogleModalityTokenCount {\n modality?: string;\n tokenCount?: number;\n}\n\nexport interface GoogleModelPricing {\n inputPerMillion: number;\n longInputPerMillion?: number;\n outputPerMillion?: number;\n longOutputPerMillion?: number;\n cachedInputPerMillion?: number;\n longCachedInputPerMillion?: number;\n outputImagePerImage?: number;\n inputByModalityPerMillion?: Partial<Record<GooglePricingModality, number>>;\n outputByModalityPerMillion?: Partial<Record<GooglePricingModality, number>>;\n cachedByModalityPerMillion?: Partial<Record<GooglePricingModality, number>>;\n longContextThreshold?: number;\n}\n\nconst GOOGLE_MODEL_PRICING: Record<string, GoogleModelPricing> = {\n 'gemini-3-pro-preview': {\n inputPerMillion: 2,\n outputPerMillion: 12,\n cachedInputPerMillion: 0.2,\n },\n 'gemini-3.1-pro-preview': {\n inputPerMillion: 2,\n longInputPerMillion: 4,\n outputPerMillion: 12,\n longOutputPerMillion: 18,\n cachedInputPerMillion: 0.2,\n longCachedInputPerMillion: 0.4,\n longContextThreshold: 200000,\n },\n 'gemini-2.5-pro': {\n inputPerMillion: 1.25,\n longInputPerMillion: 2.5,\n outputPerMillion: 10,\n longOutputPerMillion: 15,\n cachedInputPerMillion: 0.125,\n longCachedInputPerMillion: 0.25,\n longContextThreshold: 200000,\n },\n 'gemini-2.5-flash': {\n inputPerMillion: 0.3,\n outputPerMillion: 2.5,\n cachedInputPerMillion: 0.03,\n },\n 'gemini-2.5-flash-lite': {\n inputPerMillion: 0.1,\n outputPerMillion: 0.4,\n cachedInputPerMillion: 0.01,\n },\n 'gemini-3-flash-preview': {\n inputPerMillion: 0.5,\n outputPerMillion: 3,\n cachedInputPerMillion: 0.05,\n inputByModalityPerMillion: {\n text: 0.5,\n image: 0.5,\n video: 0.5,\n audio: 1,\n },\n cachedByModalityPerMillion: {\n text: 0.05,\n image: 0.05,\n video: 0.05,\n audio: 0.1,\n },\n },\n 'gemini-3.1-flash-lite-preview': {\n inputPerMillion: 0.25,\n outputPerMillion: 1.5,\n cachedInputPerMillion: 0.025,\n inputByModalityPerMillion: {\n text: 0.25,\n image: 0.25,\n video: 0.25,\n audio: 0.5,\n },\n cachedByModalityPerMillion: {\n text: 0.025,\n image: 0.025,\n video: 0.025,\n audio: 0.05,\n },\n },\n 'deep-research-pro-preview-12-2025': {\n inputPerMillion: 2,\n outputPerMillion: 12,\n cachedInputPerMillion: 0.2,\n },\n 'gemini-2.0-flash': {\n inputPerMillion: 0.1,\n outputPerMillion: 0.4,\n cachedInputPerMillion: 0.025,\n inputByModalityPerMillion: {\n text: 0.1,\n image: 0.1,\n video: 0.1,\n audio: 0.7,\n },\n cachedByModalityPerMillion: {\n text: 0.025,\n image: 0.025,\n video: 0.025,\n audio: 0.175,\n },\n },\n 'gemini-2.0-flash-001': {\n inputPerMillion: 0.1,\n outputPerMillion: 0.4,\n cachedInputPerMillion: 0.025,\n inputByModalityPerMillion: {\n text: 0.1,\n image: 0.1,\n video: 0.1,\n audio: 0.7,\n },\n cachedByModalityPerMillion: {\n text: 0.025,\n image: 0.025,\n video: 0.025,\n audio: 0.175,\n },\n },\n 'gemini-2.0-flash-lite': {\n inputPerMillion: 0.075,\n outputPerMillion: 0.3,\n },\n 'gemini-2.0-flash-lite-001': {\n inputPerMillion: 0.075,\n outputPerMillion: 0.3,\n },\n 'gemini-2.5-computer-use-preview-10-2025': {\n inputPerMillion: 1.25,\n longInputPerMillion: 2.5,\n outputPerMillion: 10,\n longOutputPerMillion: 15,\n longContextThreshold: 200000,\n },\n 'gemini-2.5-flash-preview-tts': {\n inputPerMillion: 0.5,\n outputPerMillion: 10,\n outputByModalityPerMillion: {\n audio: 10,\n },\n },\n 'gemini-2.5-pro-preview-tts': {\n inputPerMillion: 1,\n outputPerMillion: 20,\n outputByModalityPerMillion: {\n audio: 20,\n },\n },\n 'gemini-robotics-er-1.5-preview': {\n inputPerMillion: 0.3,\n outputPerMillion: 2.5,\n inputByModalityPerMillion: {\n text: 0.3,\n image: 0.3,\n video: 0.3,\n audio: 1,\n },\n },\n 'gemini-2.5-flash-image': {\n inputPerMillion: 0.3,\n outputImagePerImage: 0.039,\n },\n 'gemini-3.1-flash-image-preview': {\n inputPerMillion: 0.5,\n outputPerMillion: 3,\n outputImagePerImage: 0.045,\n },\n 'gemini-3-pro-image-preview': {\n inputPerMillion: 2,\n outputPerMillion: 12,\n outputImagePerImage: 0.134,\n },\n 'nano-banana-pro-preview': {\n inputPerMillion: 2,\n outputPerMillion: 12,\n outputImagePerImage: 0.134,\n },\n 'imagen-4.0-generate-001': {\n inputPerMillion: 0,\n outputImagePerImage: 0.04,\n },\n 'imagen-4.0-fast-generate-001': {\n inputPerMillion: 0,\n outputImagePerImage: 0.02,\n },\n 'imagen-4.0-ultra-generate-001': {\n inputPerMillion: 0,\n outputImagePerImage: 0.06,\n },\n 'imagen-3.0-capability-001': {\n inputPerMillion: 0,\n outputImagePerImage: 0.04,\n },\n 'gemma-4-31b-it': {\n inputPerMillion: 0,\n outputPerMillion: 0,\n cachedInputPerMillion: 0,\n },\n};\n\nconst GOOGLE_MODEL_PRICING_PREFIXES: Array<{ prefix: string; pricing: GoogleModelPricing }> = [\n { prefix: 'gemini-3.1-pro-preview', pricing: GOOGLE_MODEL_PRICING['gemini-3.1-pro-preview']! },\n { prefix: 'gemini-3-pro-preview', pricing: GOOGLE_MODEL_PRICING['gemini-3-pro-preview']! },\n { prefix: 'gemini-3-flash-preview', pricing: GOOGLE_MODEL_PRICING['gemini-3-flash-preview']! },\n { prefix: 'gemini-3.1-flash-lite-preview', pricing: GOOGLE_MODEL_PRICING['gemini-3.1-flash-lite-preview']! },\n { prefix: 'gemini-2.5-flash-lite-preview-', pricing: GOOGLE_MODEL_PRICING['gemini-2.5-flash-lite']! },\n { prefix: 'gemini-flash-latest', pricing: GOOGLE_MODEL_PRICING['gemini-2.5-flash']! },\n { prefix: 'gemini-flash-lite-latest', pricing: GOOGLE_MODEL_PRICING['gemini-2.5-flash-lite']! },\n { prefix: 'gemini-pro-latest', pricing: GOOGLE_MODEL_PRICING['gemini-2.5-pro']! },\n {\n prefix: 'gemma-4-',\n pricing: { inputPerMillion: 0, outputPerMillion: 0, cachedInputPerMillion: 0 },\n },\n {\n prefix: 'gemma-3-',\n pricing: { inputPerMillion: 0, outputPerMillion: 0, cachedInputPerMillion: 0 },\n },\n {\n prefix: 'gemma-3n-',\n pricing: { inputPerMillion: 0, outputPerMillion: 0, cachedInputPerMillion: 0 },\n },\n];\n\nexport interface GroqModelPricing {\n inputPerMillion: number;\n outputPerMillion: number;\n cachedInputPerMillion?: number;\n}\n\nexport interface OpenAIModelPricing {\n inputPerMillion: number;\n outputPerMillion: number;\n cachedInputPerMillion?: number;\n longInputPerMillion?: number;\n longOutputPerMillion?: number;\n longCachedInputPerMillion?: number;\n longContextThreshold?: number;\n}\n\nconst OPENAI_LONG_CONTEXT_THRESHOLD = 272_000;\n\n// Standard token pricing from https://developers.openai.com/api/docs/pricing.md.\nconst OPENAI_MODEL_PRICING: Record<string, OpenAIModelPricing> = {\n 'gpt-5.5': {\n inputPerMillion: 5,\n cachedInputPerMillion: 0.5,\n outputPerMillion: 30,\n longInputPerMillion: 10,\n longCachedInputPerMillion: 1,\n longOutputPerMillion: 45,\n longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD,\n },\n 'gpt-5.5-pro': {\n inputPerMillion: 30,\n outputPerMillion: 180,\n longInputPerMillion: 60,\n longOutputPerMillion: 270,\n longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD,\n },\n 'gpt-5.4': {\n inputPerMillion: 2.5,\n cachedInputPerMillion: 0.25,\n outputPerMillion: 15,\n longInputPerMillion: 5,\n longCachedInputPerMillion: 0.5,\n longOutputPerMillion: 22.5,\n longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD,\n },\n 'gpt-5.4-mini': { inputPerMillion: 0.75, cachedInputPerMillion: 0.075, outputPerMillion: 4.5 },\n 'gpt-5.4-nano': { inputPerMillion: 0.2, cachedInputPerMillion: 0.02, outputPerMillion: 1.25 },\n 'gpt-5.4-pro': {\n inputPerMillion: 30,\n outputPerMillion: 180,\n longInputPerMillion: 60,\n longOutputPerMillion: 270,\n longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD,\n },\n 'gpt-5.2': { inputPerMillion: 1.75, cachedInputPerMillion: 0.175, outputPerMillion: 14 },\n 'gpt-5.2-pro': { inputPerMillion: 21, outputPerMillion: 168 },\n 'gpt-5.1': { inputPerMillion: 1.25, cachedInputPerMillion: 0.125, outputPerMillion: 10 },\n 'gpt-5': { inputPerMillion: 1.25, cachedInputPerMillion: 0.125, outputPerMillion: 10 },\n 'gpt-5-mini': { inputPerMillion: 0.25, cachedInputPerMillion: 0.025, outputPerMillion: 2 },\n 'gpt-5-nano': { inputPerMillion: 0.05, cachedInputPerMillion: 0.005, outputPerMillion: 0.4 },\n 'gpt-5-pro': { inputPerMillion: 15, outputPerMillion: 120 },\n 'gpt-4.1': { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 8 },\n 'gpt-4.1-mini': { inputPerMillion: 0.4, cachedInputPerMillion: 0.1, outputPerMillion: 1.6 },\n 'gpt-4.1-nano': { inputPerMillion: 0.1, cachedInputPerMillion: 0.025, outputPerMillion: 0.4 },\n 'gpt-4o': { inputPerMillion: 2.5, cachedInputPerMillion: 1.25, outputPerMillion: 10 },\n 'gpt-4o-2024-05-13': { inputPerMillion: 5, outputPerMillion: 15 },\n 'gpt-4o-mini': { inputPerMillion: 0.15, cachedInputPerMillion: 0.075, outputPerMillion: 0.6 },\n o1: { inputPerMillion: 15, cachedInputPerMillion: 7.5, outputPerMillion: 60 },\n 'o1-pro': { inputPerMillion: 150, outputPerMillion: 600 },\n 'o3-pro': { inputPerMillion: 20, outputPerMillion: 80 },\n o3: { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 8 },\n 'o4-mini': { inputPerMillion: 1.1, cachedInputPerMillion: 0.275, outputPerMillion: 4.4 },\n 'o3-mini': { inputPerMillion: 1.1, cachedInputPerMillion: 0.55, outputPerMillion: 4.4 },\n 'o1-mini': { inputPerMillion: 1.1, cachedInputPerMillion: 0.55, outputPerMillion: 4.4 },\n 'gpt-4-turbo': { inputPerMillion: 10, outputPerMillion: 30 },\n 'gpt-4-turbo-2024-04-09': { inputPerMillion: 10, outputPerMillion: 30 },\n 'gpt-4-0125-preview': { inputPerMillion: 10, outputPerMillion: 30 },\n 'gpt-4-1106-preview': { inputPerMillion: 10, outputPerMillion: 30 },\n 'gpt-4-1106-vision-preview': { inputPerMillion: 10, outputPerMillion: 30 },\n 'gpt-4': { inputPerMillion: 30, outputPerMillion: 60 },\n 'gpt-4-0613': { inputPerMillion: 30, outputPerMillion: 60 },\n 'gpt-4-0314': { inputPerMillion: 30, outputPerMillion: 60 },\n 'gpt-4-32k': { inputPerMillion: 60, outputPerMillion: 120 },\n 'gpt-3.5-turbo': { inputPerMillion: 0.5, outputPerMillion: 1.5 },\n 'gpt-3.5-turbo-0125': { inputPerMillion: 0.5, outputPerMillion: 1.5 },\n 'gpt-3.5-turbo-1106': { inputPerMillion: 1, outputPerMillion: 2 },\n 'gpt-3.5-turbo-0613': { inputPerMillion: 1.5, outputPerMillion: 2 },\n 'gpt-3.5-0301': { inputPerMillion: 1.5, outputPerMillion: 2 },\n 'gpt-3.5-turbo-instruct': { inputPerMillion: 1.5, outputPerMillion: 2 },\n 'gpt-3.5-turbo-16k-0613': { inputPerMillion: 3, outputPerMillion: 4 },\n 'davinci-002': { inputPerMillion: 2, outputPerMillion: 2 },\n 'babbage-002': { inputPerMillion: 0.4, outputPerMillion: 0.4 },\n};\n\nconst OPENAI_MODEL_PRICING_PREFIXES: Array<{ prefix: string; pricing: OpenAIModelPricing }> = [\n { prefix: 'gpt-5.5-pro', pricing: OPENAI_MODEL_PRICING['gpt-5.5-pro']! },\n { prefix: 'gpt-5.5', pricing: OPENAI_MODEL_PRICING['gpt-5.5']! },\n { prefix: 'gpt-5.4-mini', pricing: OPENAI_MODEL_PRICING['gpt-5.4-mini']! },\n { prefix: 'gpt-5.4-nano', pricing: OPENAI_MODEL_PRICING['gpt-5.4-nano']! },\n { prefix: 'gpt-5.4-pro', pricing: OPENAI_MODEL_PRICING['gpt-5.4-pro']! },\n { prefix: 'gpt-5.4', pricing: OPENAI_MODEL_PRICING['gpt-5.4']! },\n { prefix: 'gpt-5.2-pro', pricing: OPENAI_MODEL_PRICING['gpt-5.2-pro']! },\n { prefix: 'gpt-5.2', pricing: OPENAI_MODEL_PRICING['gpt-5.2']! },\n { prefix: 'gpt-5.1', pricing: OPENAI_MODEL_PRICING['gpt-5.1']! },\n { prefix: 'gpt-5-mini', pricing: OPENAI_MODEL_PRICING['gpt-5-mini']! },\n { prefix: 'gpt-5-nano', pricing: OPENAI_MODEL_PRICING['gpt-5-nano']! },\n { prefix: 'gpt-5-pro', pricing: OPENAI_MODEL_PRICING['gpt-5-pro']! },\n { prefix: 'gpt-5', pricing: OPENAI_MODEL_PRICING['gpt-5']! },\n { prefix: 'gpt-4.1-mini', pricing: OPENAI_MODEL_PRICING['gpt-4.1-mini']! },\n { prefix: 'gpt-4.1-nano', pricing: OPENAI_MODEL_PRICING['gpt-4.1-nano']! },\n { prefix: 'gpt-4.1', pricing: OPENAI_MODEL_PRICING['gpt-4.1']! },\n { prefix: 'gpt-4o-mini', pricing: OPENAI_MODEL_PRICING['gpt-4o-mini']! },\n { prefix: 'gpt-4o', pricing: OPENAI_MODEL_PRICING['gpt-4o']! },\n { prefix: 'o3-pro', pricing: OPENAI_MODEL_PRICING['o3-pro']! },\n { prefix: 'o3-mini', pricing: OPENAI_MODEL_PRICING['o3-mini']! },\n { prefix: 'o4-mini', pricing: OPENAI_MODEL_PRICING['o4-mini']! },\n { prefix: 'o1-pro', pricing: OPENAI_MODEL_PRICING['o1-pro']! },\n { prefix: 'o1-mini', pricing: OPENAI_MODEL_PRICING['o1-mini']! },\n { prefix: 'o3', pricing: OPENAI_MODEL_PRICING.o3! },\n { prefix: 'o1', pricing: OPENAI_MODEL_PRICING.o1! },\n { prefix: 'gpt-4-turbo', pricing: OPENAI_MODEL_PRICING['gpt-4-turbo']! },\n { prefix: 'gpt-4-32k', pricing: OPENAI_MODEL_PRICING['gpt-4-32k']! },\n { prefix: 'gpt-4', pricing: OPENAI_MODEL_PRICING['gpt-4']! },\n { prefix: 'gpt-3.5-turbo', pricing: OPENAI_MODEL_PRICING['gpt-3.5-turbo']! },\n];\n\nconst GROQ_MODEL_PRICING: Record<string, GroqModelPricing> = {\n 'llama-3.1-8b-instant': { inputPerMillion: 0.05, outputPerMillion: 0.08 },\n 'llama-3.3-70b-versatile': { inputPerMillion: 0.59, outputPerMillion: 0.79 },\n 'meta-llama/llama-4-scout-17b-16e-instruct': { inputPerMillion: 0.11, outputPerMillion: 0.34 },\n 'moonshotai/kimi-k2-instruct': { inputPerMillion: 1.0, outputPerMillion: 3.0 },\n 'openai/gpt-oss-120b': { inputPerMillion: 0.15, cachedInputPerMillion: 0.075, outputPerMillion: 0.6 },\n 'openai/gpt-oss-20b': { inputPerMillion: 0.075, cachedInputPerMillion: 0.037, outputPerMillion: 0.3 },\n 'qwen/qwen3-32b': { inputPerMillion: 0.29, outputPerMillion: 0.59 },\n};\n\nexport interface XAITextPricing {\n inputPerMillion: number;\n outputPerMillion: number;\n cachedInputPerMillion?: number;\n}\n\nconst XAI_MODEL_PRICING: Record<string, XAITextPricing> = {\n 'grok-4-0709': { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },\n 'grok-4': { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },\n 'grok-4-latest': { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },\n 'grok-4-fast-reasoning': { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },\n 'grok-4-fast-non-reasoning': { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },\n 'grok-4-1-fast-reasoning': { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },\n 'grok-4-1-fast-non-reasoning': { inputPerMillion: 2, cachedInputPerMillion: 0.5, outputPerMillion: 5 },\n 'grok-4.20-0309-reasoning': { inputPerMillion: 20, cachedInputPerMillion: 2, outputPerMillion: 60 },\n 'grok-4.20-0309-non-reasoning': { inputPerMillion: 20, cachedInputPerMillion: 2, outputPerMillion: 60 },\n 'grok-4.20-multi-agent-0309': { inputPerMillion: 20, cachedInputPerMillion: 2, outputPerMillion: 60 },\n 'grok-code-fast-1': { inputPerMillion: 2, cachedInputPerMillion: 0.2, outputPerMillion: 15 },\n 'grok-3': { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },\n 'grok-3-latest': { inputPerMillion: 30, cachedInputPerMillion: 7.5, outputPerMillion: 150 },\n 'grok-3-mini': { inputPerMillion: 3, cachedInputPerMillion: 0.75, outputPerMillion: 5 },\n 'grok-3-mini-latest': { inputPerMillion: 3, cachedInputPerMillion: 0.75, outputPerMillion: 5 },\n};\n\nexport interface CloudflareModelPricing {\n inputPerMillion: number;\n outputPerMillion: number;\n cachedInputPerMillion?: number;\n}\n\nconst CLOUDFLARE_MODEL_PRICING: Record<string, CloudflareModelPricing> = {\n '@cf/meta/llama-3.2-1b-instruct': { inputPerMillion: 0.027, outputPerMillion: 0.201 },\n '@cf/meta/llama-3.2-3b-instruct': { inputPerMillion: 0.051, outputPerMillion: 0.335 },\n '@cf/meta/llama-3.1-8b-instruct-fp8-fast': { inputPerMillion: 0.045, outputPerMillion: 0.384 },\n '@cf/meta/llama-3.2-11b-vision-instruct': { inputPerMillion: 0.049, outputPerMillion: 0.676 },\n '@cf/meta/llama-3.1-70b-instruct-fp8-fast': { inputPerMillion: 0.293, outputPerMillion: 2.253 },\n '@cf/meta/llama-3.3-70b-instruct-fp8-fast': { inputPerMillion: 0.293, outputPerMillion: 2.253 },\n '@cf/deepseek-ai/deepseek-r1-distill-qwen-32b': { inputPerMillion: 0.497, outputPerMillion: 4.881 },\n '@cf/mistral/mistral-7b-instruct-v0.1': { inputPerMillion: 0.11, outputPerMillion: 0.19 },\n '@cf/mistralai/mistral-small-3.1-24b-instruct': { inputPerMillion: 0.351, outputPerMillion: 0.555 },\n '@cf/meta/llama-3.1-8b-instruct': { inputPerMillion: 0.282, outputPerMillion: 0.827 },\n '@cf/meta/llama-3.1-8b-instruct-fp8': { inputPerMillion: 0.152, outputPerMillion: 0.287 },\n '@cf/meta/llama-3.1-8b-instruct-awq': { inputPerMillion: 0.123, outputPerMillion: 0.266 },\n '@cf/meta/llama-3-8b-instruct': { inputPerMillion: 0.282, outputPerMillion: 0.827 },\n '@cf/meta/llama-3-8b-instruct-awq': { inputPerMillion: 0.123, outputPerMillion: 0.266 },\n '@cf/meta/llama-2-7b-chat-fp16': { inputPerMillion: 0.556, outputPerMillion: 6.667 },\n '@cf/meta/llama-guard-3-8b': { inputPerMillion: 0.484, outputPerMillion: 0.03 },\n '@cf/meta/llama-4-scout-17b-16e-instruct': { inputPerMillion: 0.27, outputPerMillion: 0.85 },\n '@cf/google/gemma-3-12b-it': { inputPerMillion: 0.345, outputPerMillion: 0.556 },\n '@cf/qwen/qwq-32b': { inputPerMillion: 0.66, outputPerMillion: 1.0 },\n '@cf/qwen/qwen2.5-coder-32b-instruct': { inputPerMillion: 0.66, outputPerMillion: 1.0 },\n '@cf/qwen/qwen3-30b-a3b-fp8': { inputPerMillion: 0.051, outputPerMillion: 0.335 },\n '@cf/openai/gpt-oss-120b': { inputPerMillion: 0.35, outputPerMillion: 0.75 },\n '@cf/openai/gpt-oss-20b': { inputPerMillion: 0.2, outputPerMillion: 0.3 },\n '@cf/aisingapore/gemma-sea-lion-v4-27b-it': { inputPerMillion: 0.351, outputPerMillion: 0.555 },\n '@cf/ibm-granite/granite-4.0-h-micro': { inputPerMillion: 0.017, outputPerMillion: 0.112 },\n '@cf/zai-org/glm-4.7-flash': { inputPerMillion: 0.06, outputPerMillion: 0.4 },\n '@cf/nvidia/nemotron-3-120b-a12b': { inputPerMillion: 0.5, outputPerMillion: 1.5 },\n '@cf/moonshotai/kimi-k2.5': { inputPerMillion: 0.6, cachedInputPerMillion: 0.1, outputPerMillion: 3.0 },\n};\n\nfunction normalizeModelId(modelId: string | null | undefined): string {\n return (modelId || '').trim().toLowerCase();\n}\n\nfunction normalizeOpenAIModelId(modelId: string | null | undefined): string {\n return normalizeModelId(modelId).replace(/^openai\\//, '');\n}\n\nfunction normalizeGoogleModelId(modelId: string | null | undefined): string {\n return normalizeModelId(modelId)\n .replace(/^google\\//, '')\n .replace(/^models\\//, '')\n .replace(/^publishers\\/google\\/models\\//, '');\n}\n\nfunction normalizeCloudflareModelId(modelId: string | null | undefined): string {\n const trimmed = (modelId || '').trim();\n if (trimmed.startsWith('@cf/')) return trimmed;\n return `@cf/${trimmed.replace(/^@cf\\//, '')}`;\n}\n\nfunction roundCost(value: number): number {\n return Number(value.toFixed(12));\n}\n\nfunction normalizeModality(modality: string | undefined): GooglePricingModality {\n const normalized = (modality || '').trim().toLowerCase();\n\n if (normalized === 'text') return 'text';\n if (normalized === 'image') return 'image';\n if (normalized === 'video') return 'video';\n if (normalized === 'audio') return 'audio';\n if (normalized === 'document') return 'document';\n return 'unspecified';\n}\n\nfunction toModalityCounts(\n details: GoogleModalityTokenCount[] | undefined\n): Partial<Record<GooglePricingModality, number>> {\n const counts: Partial<Record<GooglePricingModality, number>> = {};\n\n for (const detail of details || []) {\n const modality = normalizeModality(detail.modality);\n const tokenCount = Math.max(detail.tokenCount ?? 0, 0);\n counts[modality] = (counts[modality] ?? 0) + tokenCount;\n }\n\n return counts;\n}\n\nfunction sumModalityCosts(\n counts: Partial<Record<GooglePricingModality, number>>,\n modalityRates: Partial<Record<GooglePricingModality, number>> | undefined,\n defaultRate: number\n): number {\n let total = 0;\n\n for (const [modality, tokenCount] of Object.entries(counts)) {\n if (!tokenCount) continue;\n const rate = modalityRates?.[modality as GooglePricingModality] ?? defaultRate;\n total += (tokenCount / TOKENS_PER_MILLION) * rate;\n }\n\n return total;\n}\n\nfunction sumModalityCostNumerator(\n counts: Partial<Record<GooglePricingModality, number>>,\n modalityRates: Partial<Record<GooglePricingModality, number>> | undefined,\n defaultRate: number\n): number {\n let total = 0;\n\n for (const [modality, tokenCount] of Object.entries(counts)) {\n if (!tokenCount) continue;\n const rate = modalityRates?.[modality as GooglePricingModality] ?? defaultRate;\n total += tokenCount * ratePerMillionMicrocents(rate);\n }\n\n return total;\n}\n\nfunction ratePerMillionMicrocents(usdPerMillion: number, multiplier = 1): number {\n return Math.round(usdPerMillion * multiplier * MICROCENTS_PER_DOLLAR);\n}\n\nfunction ceilDiv(numerator: number, divisor: number): number {\n return Math.ceil(numerator / divisor);\n}\n\nexport function getAnthropicModelPricing(modelId: string | null | undefined): AnthropicModelPricing | null {\n const normalized = normalizeModelId(modelId);\n let best: { prefix: string; pricing: AnthropicModelPricing } | null = null;\n for (const [prefix, pricing] of ANTHROPIC_MODEL_PRICING) {\n if (normalized.startsWith(prefix) && (!best || prefix.length > best.prefix.length)) {\n best = { prefix, pricing };\n }\n }\n return best ? { ...best.pricing } : null;\n}\n\nexport function calculateAnthropicUsageCost(\n modelId: string | null | undefined,\n buckets: AnthropicUsageBuckets\n): number | undefined {\n const pricing = getAnthropicModelPricing(modelId);\n if (!pricing) return undefined;\n\n const inputRate = pricing.inputPerMillion / TOKENS_PER_MILLION;\n const outputRate = pricing.outputPerMillion / TOKENS_PER_MILLION;\n\n return roundCost(\n buckets.inputTokens * inputRate +\n buckets.cacheWrite5mTokens * inputRate * 1.25 +\n buckets.cacheWrite1hTokens * inputRate * 2 +\n buckets.cacheReadTokens * inputRate * 0.1 +\n buckets.outputTokens * outputRate\n );\n}\n\nexport function getCerebrasModelPricing(modelId: string | null | undefined): CerebrasModelPricing | undefined {\n const pricing = CEREBRAS_MODEL_PRICING[normalizeModelId(modelId)];\n return pricing ? { ...pricing } : undefined;\n}\n\nexport function calculateCerebrasUsageCost(\n modelId: string | null | undefined,\n usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens'>\n): number | undefined {\n const pricing = getCerebrasModelPricing(modelId);\n if (!pricing) return undefined;\n\n return roundCost(\n (usage.promptTokens * pricing.inputPerMillion +\n usage.completionTokens * pricing.outputPerMillion) /\n TOKENS_PER_MILLION\n );\n}\n\nexport function getGoogleModelPricing(modelId: string): GoogleModelPricing | undefined {\n const normalizedModelId = normalizeGoogleModelId(modelId);\n const exact = GOOGLE_MODEL_PRICING[normalizedModelId];\n if (exact) return { ...exact };\n\n const prefix = GOOGLE_MODEL_PRICING_PREFIXES.find((entry) => normalizedModelId.startsWith(entry.prefix));\n return prefix ? { ...prefix.pricing } : undefined;\n}\n\nexport function calculateGoogleUsageCost(\n modelId: string,\n usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'reasoningTokens' | 'cachedTokens'> & {\n promptTokenDetails?: GoogleModalityTokenCount[];\n completionTokenDetails?: GoogleModalityTokenCount[];\n cachedTokenDetails?: GoogleModalityTokenCount[];\n },\n imageCount = 0\n): number | undefined {\n const pricing = getGoogleModelPricing(modelId);\n if (!pricing) return undefined;\n\n const cachedTokens = usage.cachedTokens ?? 0;\n const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);\n const useLongContext = pricing.longContextThreshold != null && usage.promptTokens > pricing.longContextThreshold;\n\n const inputRate = useLongContext ? (pricing.longInputPerMillion ?? pricing.inputPerMillion) : pricing.inputPerMillion;\n const outputRate = useLongContext\n ? (pricing.longOutputPerMillion ?? pricing.outputPerMillion ?? 0)\n : (pricing.outputPerMillion ?? 0);\n const cachedRate = useLongContext\n ? (pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? 0)\n : (pricing.cachedInputPerMillion ?? 0);\n const billableOutputTokens = usage.completionTokens + (usage.reasoningTokens ?? 0);\n const promptModalityCounts = toModalityCounts(usage.promptTokenDetails);\n const cachedModalityCounts = toModalityCounts(usage.cachedTokenDetails);\n const uncachedPromptModalityCounts: Partial<Record<GooglePricingModality, number>> = {};\n\n for (const modality of new Set<GooglePricingModality>([\n ...(Object.keys(promptModalityCounts) as GooglePricingModality[]),\n ...(Object.keys(cachedModalityCounts) as GooglePricingModality[]),\n ])) {\n uncachedPromptModalityCounts[modality] = Math.max(\n (promptModalityCounts[modality] ?? 0) - (cachedModalityCounts[modality] ?? 0),\n 0\n );\n }\n\n const completionModalityCounts = toModalityCounts(usage.completionTokenDetails);\n if (usage.reasoningTokens) {\n completionModalityCounts.text = (completionModalityCounts.text ?? 0) + usage.reasoningTokens;\n }\n\n const hasPromptModalityPricing = Object.keys(uncachedPromptModalityCounts).length > 0 && pricing.inputByModalityPerMillion;\n const hasCachedModalityPricing = Object.keys(cachedModalityCounts).length > 0 && pricing.cachedByModalityPerMillion;\n const hasOutputModalityPricing = Object.keys(completionModalityCounts).length > 0 && pricing.outputByModalityPerMillion;\n\n const inputCost = hasPromptModalityPricing\n ? sumModalityCosts(uncachedPromptModalityCounts, pricing.inputByModalityPerMillion, inputRate)\n : (uncachedPromptTokens / TOKENS_PER_MILLION) * inputRate;\n const cachedCost = hasCachedModalityPricing\n ? sumModalityCosts(cachedModalityCounts, pricing.cachedByModalityPerMillion, cachedRate)\n : (cachedTokens / TOKENS_PER_MILLION) * cachedRate;\n const outputCost = hasOutputModalityPricing\n ? sumModalityCosts(completionModalityCounts, pricing.outputByModalityPerMillion, outputRate)\n : (billableOutputTokens / TOKENS_PER_MILLION) * outputRate;\n const imageCost = imageCount * (pricing.outputImagePerImage ?? 0);\n\n return roundCost(inputCost + cachedCost + outputCost + imageCost);\n}\n\nexport function getOpenAIModelPricing(modelId: string): OpenAIModelPricing | undefined {\n const normalizedModelId = normalizeOpenAIModelId(modelId);\n const exact = OPENAI_MODEL_PRICING[normalizedModelId];\n if (exact) return { ...exact };\n\n const prefix = OPENAI_MODEL_PRICING_PREFIXES.find((entry) => normalizedModelId.startsWith(entry.prefix));\n return prefix ? { ...prefix.pricing } : undefined;\n}\n\nexport function calculateOpenAIUsageCost(\n modelId: string,\n usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>\n): number | undefined {\n const pricing = getOpenAIModelPricing(modelId);\n if (!pricing) return undefined;\n\n const cachedTokens = usage.cachedTokens ?? 0;\n const promptTokens = Math.max(usage.promptTokens, 0);\n const uncachedPromptTokens = Math.max(0, promptTokens - cachedTokens);\n const useLongContext = pricing.longContextThreshold != null && promptTokens >= pricing.longContextThreshold;\n const inputRate = useLongContext ? (pricing.longInputPerMillion ?? pricing.inputPerMillion) : pricing.inputPerMillion;\n const outputRate = useLongContext ? (pricing.longOutputPerMillion ?? pricing.outputPerMillion) : pricing.outputPerMillion;\n const cachedRate = useLongContext\n ? (pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? pricing.inputPerMillion)\n : (pricing.cachedInputPerMillion ?? pricing.inputPerMillion);\n\n const inputCost = (uncachedPromptTokens / TOKENS_PER_MILLION) * inputRate;\n const cachedCost = (cachedTokens / TOKENS_PER_MILLION) * cachedRate;\n const outputCost = (Math.max(usage.completionTokens, 0) / TOKENS_PER_MILLION) * outputRate;\n\n return roundCost(inputCost + cachedCost + outputCost);\n}\n\nexport function getGroqModelPricing(modelId: string): GroqModelPricing | undefined {\n const pricing = GROQ_MODEL_PRICING[normalizeModelId(modelId)];\n return pricing ? { ...pricing } : undefined;\n}\n\nexport function calculateGroqUsageCost(\n modelId: string,\n usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>\n): number | undefined {\n const pricing = getGroqModelPricing(modelId);\n if (!pricing) return undefined;\n\n const cachedTokens = usage.cachedTokens ?? 0;\n const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);\n const inputCost = (uncachedPromptTokens / TOKENS_PER_MILLION) * pricing.inputPerMillion;\n const cachedInputCost = pricing.cachedInputPerMillion\n ? (cachedTokens / TOKENS_PER_MILLION) * pricing.cachedInputPerMillion\n : 0;\n const outputCost = (usage.completionTokens / TOKENS_PER_MILLION) * pricing.outputPerMillion;\n\n return roundCost(inputCost + cachedInputCost + outputCost);\n}\n\nexport function getXAITextPricing(modelId: string): XAITextPricing | undefined {\n const pricing = XAI_MODEL_PRICING[normalizeModelId(modelId)];\n return pricing ? { ...pricing } : undefined;\n}\n\nexport function calculateXAIUsageCost(\n modelId: string,\n usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>\n): number | undefined {\n const pricing = getXAITextPricing(modelId);\n if (!pricing) return undefined;\n\n const cachedTokens = usage.cachedTokens ?? 0;\n const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);\n const inputCost = (uncachedPromptTokens / TOKENS_PER_MILLION) * pricing.inputPerMillion;\n const cachedCost = pricing.cachedInputPerMillion\n ? (cachedTokens / TOKENS_PER_MILLION) * pricing.cachedInputPerMillion\n : 0;\n const outputCost = (usage.completionTokens / TOKENS_PER_MILLION) * pricing.outputPerMillion;\n\n return roundCost(inputCost + cachedCost + outputCost);\n}\n\nexport function ticksToUsd(ticks: number | undefined): number | undefined {\n if (typeof ticks !== 'number') return undefined;\n return roundCost(ticks / XAI_TICKS_PER_DOLLAR);\n}\n\nexport function getCloudflareModelPricing(modelId: string): CloudflareModelPricing | undefined {\n const pricing = CLOUDFLARE_MODEL_PRICING[normalizeCloudflareModelId(modelId)];\n return pricing ? { ...pricing } : undefined;\n}\n\nexport function calculateCloudflareUsageCost(\n modelId: string,\n usage: Pick<ProviderUsageLike, 'promptTokens' | 'completionTokens' | 'cachedTokens'>\n): number | undefined {\n const pricing = getCloudflareModelPricing(modelId);\n if (!pricing) return undefined;\n\n const cachedTokens = usage.cachedTokens ?? 0;\n const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);\n const inputCost = (uncachedPromptTokens / TOKENS_PER_MILLION) * pricing.inputPerMillion;\n const cachedInputCost = pricing.cachedInputPerMillion\n ? (cachedTokens / TOKENS_PER_MILLION) * pricing.cachedInputPerMillion\n : 0;\n const outputCost = (usage.completionTokens / TOKENS_PER_MILLION) * pricing.outputPerMillion;\n\n return roundCost(inputCost + cachedInputCost + outputCost);\n}\n\nexport function getProviderModelPricing(\n provider: ProviderPricingName,\n modelId: string | null | undefined\n): ProviderModelPricing | undefined {\n if (provider === 'anthropic') {\n const pricing = getAnthropicModelPricing(modelId);\n return pricing\n ? {\n inputPerMillion: pricing.inputPerMillion,\n outputPerMillion: pricing.outputPerMillion,\n cachedInputPerMillion: roundCost(pricing.inputPerMillion * 0.1),\n source: 'anthropic-static',\n }\n : undefined;\n }\n\n if (provider === 'cerebras') {\n const pricing = getCerebrasModelPricing(modelId);\n return pricing ? { ...pricing, source: 'cerebras-static' } : undefined;\n }\n\n if (provider === 'google') {\n const pricing = getGoogleModelPricing(modelId || '');\n return pricing\n ? {\n inputPerMillion: pricing.inputPerMillion,\n outputPerMillion: pricing.outputPerMillion ?? 0,\n cachedInputPerMillion: pricing.cachedInputPerMillion,\n longInputPerMillion: pricing.longInputPerMillion,\n longOutputPerMillion: pricing.longOutputPerMillion,\n longCachedInputPerMillion: pricing.longCachedInputPerMillion,\n longContextThreshold: pricing.longContextThreshold,\n source: 'google-static',\n }\n : undefined;\n }\n\n if (provider === 'groq') {\n const pricing = getGroqModelPricing(modelId || '');\n return pricing ? { ...pricing, source: 'groq-static' } : undefined;\n }\n\n if (provider === 'openai') {\n const pricing = getOpenAIModelPricing(modelId || '');\n return pricing ? { ...pricing, source: 'openai-static' } : undefined;\n }\n\n if (provider === 'xai') {\n const pricing = getXAITextPricing(modelId || '');\n return pricing ? { ...pricing, source: 'xai-static' } : undefined;\n }\n\n if (provider === 'cloudflare') {\n const pricing = getCloudflareModelPricing(modelId || '');\n return pricing ? { ...pricing, source: 'cloudflare-static' } : undefined;\n }\n\n return undefined;\n}\n\nfunction costFromStandardBuckets(\n usage: PlatformTokenUsageLike,\n pricing: ProviderModelPricing,\n options: { billReasoningAsOutput?: boolean } = {}\n): number {\n const cachedTokens = Math.max(usage.cached_tokens ?? 0, 0);\n const inputTokens = Math.max(usage.input_tokens, 0);\n const uncachedInputTokens = Math.max(inputTokens - cachedTokens, 0);\n const outputTokens = Math.max(usage.output_tokens, 0);\n const reasoningTokens = options.billReasoningAsOutput ? Math.max(usage.reasoning_tokens ?? 0, 0) : 0;\n const useLongContext = pricing.longContextThreshold != null && inputTokens >= pricing.longContextThreshold;\n const inputRate = useLongContext ? (pricing.longInputPerMillion ?? pricing.inputPerMillion) : pricing.inputPerMillion;\n const outputRate = useLongContext ? (pricing.longOutputPerMillion ?? pricing.outputPerMillion) : pricing.outputPerMillion;\n const cachedRate = useLongContext\n ? (pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? pricing.inputPerMillion)\n : (pricing.cachedInputPerMillion ?? pricing.inputPerMillion);\n\n return ceilDiv(\n uncachedInputTokens * ratePerMillionMicrocents(inputRate) +\n cachedTokens * ratePerMillionMicrocents(cachedRate) +\n (outputTokens + reasoningTokens) * ratePerMillionMicrocents(outputRate),\n TOKENS_PER_MILLION\n );\n}\n\nfunction costFromAnthropicBuckets(usage: PlatformTokenUsageLike, pricing: ProviderModelPricing): number {\n const cacheCreationTokens = Math.max(usage.cache_creation_input_tokens ?? 0, 0);\n const cacheReadTokens = Math.max(usage.cache_read_input_tokens ?? 0, 0);\n const cacheWrite1hTokens = Math.max(usage.cache_creation_1h_input_tokens ?? 0, 0);\n const cacheWrite5mTokens = Math.max(\n usage.cache_creation_5m_input_tokens ?? cacheCreationTokens - cacheWrite1hTokens,\n 0\n );\n const uncachedInputTokens = Math.max(usage.input_tokens - cacheCreationTokens - cacheReadTokens, 0);\n\n return ceilDiv(\n uncachedInputTokens * ratePerMillionMicrocents(pricing.inputPerMillion) +\n cacheWrite5mTokens * ratePerMillionMicrocents(pricing.inputPerMillion, 1.25) +\n cacheWrite1hTokens * ratePerMillionMicrocents(pricing.inputPerMillion, 2) +\n cacheReadTokens * ratePerMillionMicrocents(pricing.inputPerMillion, 0.1) +\n Math.max(usage.output_tokens, 0) * ratePerMillionMicrocents(pricing.outputPerMillion),\n TOKENS_PER_MILLION\n );\n}\n\nfunction costFromGoogleBuckets(usage: PlatformTokenUsageLike, pricing: GoogleModelPricing): number {\n const cachedTokens = Math.max(usage.cached_tokens ?? 0, 0);\n const inputTokens = Math.max(usage.input_tokens, 0);\n const outputTokens = Math.max(usage.output_tokens, 0);\n const reasoningTokens = Math.max(usage.reasoning_tokens ?? 0, 0);\n const uncachedInputTokens = Math.max(inputTokens - cachedTokens, 0);\n const useLongContext = pricing.longContextThreshold != null && inputTokens > pricing.longContextThreshold;\n\n const inputRate = useLongContext ? (pricing.longInputPerMillion ?? pricing.inputPerMillion) : pricing.inputPerMillion;\n const outputRate = useLongContext\n ? (pricing.longOutputPerMillion ?? pricing.outputPerMillion ?? 0)\n : (pricing.outputPerMillion ?? 0);\n const cachedRate = useLongContext\n ? (pricing.longCachedInputPerMillion ?? pricing.cachedInputPerMillion ?? 0)\n : (pricing.cachedInputPerMillion ?? 0);\n\n const promptModalityCounts = toModalityCounts(usage.prompt_token_details);\n const cachedModalityCounts = toModalityCounts(usage.cached_token_details);\n const uncachedPromptModalityCounts: Partial<Record<GooglePricingModality, number>> = {};\n\n for (const modality of new Set<GooglePricingModality>([\n ...(Object.keys(promptModalityCounts) as GooglePricingModality[]),\n ...(Object.keys(cachedModalityCounts) as GooglePricingModality[]),\n ])) {\n uncachedPromptModalityCounts[modality] = Math.max(\n (promptModalityCounts[modality] ?? 0) - (cachedModalityCounts[modality] ?? 0),\n 0\n );\n }\n\n const completionModalityCounts = toModalityCounts(usage.completion_token_details);\n if (reasoningTokens) {\n completionModalityCounts.text = (completionModalityCounts.text ?? 0) + reasoningTokens;\n }\n\n const hasPromptModalityPricing =\n Object.keys(uncachedPromptModalityCounts).length > 0 && pricing.inputByModalityPerMillion;\n const hasCachedModalityPricing = Object.keys(cachedModalityCounts).length > 0 && pricing.cachedByModalityPerMillion;\n const hasOutputModalityPricing =\n Object.keys(completionModalityCounts).length > 0 && pricing.outputByModalityPerMillion;\n\n const tokenNumerator =\n (hasPromptModalityPricing\n ? sumModalityCostNumerator(uncachedPromptModalityCounts, pricing.inputByModalityPerMillion, inputRate)\n : uncachedInputTokens * ratePerMillionMicrocents(inputRate)) +\n (hasCachedModalityPricing\n ? sumModalityCostNumerator(cachedModalityCounts, pricing.cachedByModalityPerMillion, cachedRate)\n : cachedTokens * ratePerMillionMicrocents(cachedRate)) +\n (hasOutputModalityPricing\n ? sumModalityCostNumerator(completionModalityCounts, pricing.outputByModalityPerMillion, outputRate)\n : (outputTokens + reasoningTokens) * ratePerMillionMicrocents(outputRate));\n const imageMicrocents =\n Math.max(usage.image_count ?? 0, 0) * Math.round((pricing.outputImagePerImage ?? 0) * MICROCENTS_PER_DOLLAR);\n\n return ceilDiv(tokenNumerator, TOKENS_PER_MILLION) + imageMicrocents;\n}\n\nexport function calculateProviderUsageCostMicrocents(\n provider: ProviderPricingName,\n modelId: string,\n usage: PlatformTokenUsageLike\n): number | undefined {\n const pricing = getProviderModelPricing(provider, modelId);\n if (!pricing) return undefined;\n\n if (provider === 'anthropic') {\n return costFromAnthropicBuckets(usage, pricing);\n }\n\n if (provider === 'google') {\n const googlePricing = getGoogleModelPricing(modelId);\n return googlePricing ? costFromGoogleBuckets(usage, googlePricing) : undefined;\n }\n\n return costFromStandardBuckets(usage, pricing, {\n billReasoningAsOutput: false,\n });\n}\n"],"mappings":";AAAA,IAAM,qBAAqB;AACpB,IAAM,wBAAwB;AACrC,IAAM,uBAAuB;AA0D7B,IAAM,0BAAmF;AAAA,EACvF,CAAC,kBAAkB,EAAE,iBAAiB,IAAI,kBAAkB,GAAG,CAAC;AAAA,EAChE,CAAC,iBAAiB,EAAE,iBAAiB,IAAI,kBAAkB,GAAG,CAAC;AAAA,EAC/D,CAAC,mBAAmB,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,CAAC;AAAA,EAChE,CAAC,mBAAmB,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,CAAC;AAAA,EAChE,CAAC,mBAAmB,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,CAAC;AAAA,EAChE,CAAC,mBAAmB,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,CAAC;AAAA,EAChE,CAAC,mBAAmB,EAAE,iBAAiB,IAAI,kBAAkB,GAAG,CAAC;AAAA,EACjE,CAAC,iBAAiB,EAAE,iBAAiB,IAAI,kBAAkB,GAAG,CAAC;AAAA,EAC/D,CAAC,qBAAqB,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,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AA,EAChD;AAEA,MAAI,aAAa,UAAU;AACzB,UAAM,gBAAgB,sBAAsB,OAAO;AACnD,WAAO,gBAAgB,sBAAsB,OAAO,aAAa,IAAI;AAAA,EACvE;AAEA,SAAO,wBAAwB,OAAO,SAAS;AAAA,IAC7C,uBAAuB;AAAA,EACzB,CAAC;AACH;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@standardagents/provider-pricing",
|
|
3
|
+
"version": "0.22.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org/"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"description": "Pure provider pricing tables and cost helpers for Standard Agents",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "cd ../.. && vitest run --dir packages/provider-pricing"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"tsup": "^8.3.5",
|
|
31
|
+
"typescript": "^5.9.0"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"standardagents",
|
|
35
|
+
"pricing",
|
|
36
|
+
"billing",
|
|
37
|
+
"llm"
|
|
38
|
+
],
|
|
39
|
+
"author": "FormKit Inc.",
|
|
40
|
+
"license": "UNLICENSED"
|
|
41
|
+
}
|