Skip to content

Commit 817990a

Browse files
committed
fix: adjust cache read prices and add context window to OpenAI models; ensure context window fallback in Anthropic and Gemini handlers
1 parent 663c9c7 commit 817990a

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

packages/types/src/model.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export const modelInfoSchema = z.object({
8282
minTokensPerCachePoint: z.number().optional(),
8383
maxCachePoints: z.number().optional(),
8484
cachableFields: z.array(z.string()).optional(),
85-
// ...existing code...
8685
})
8786

8887
export type ModelInfo = z.infer<typeof modelInfoSchema>

packages/types/src/providers/openai.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const openAiNativeModels = {
3434
name: "flex",
3535
inputPrice: 0.625,
3636
outputPrice: 5.0,
37-
cacheReadsPrice: 0.063,
37+
cacheReadsPrice: 0.0625,
3838
},
3939
],
4040
description: "GPT-5: The best model for coding and agentic tasks across domains",
@@ -55,9 +55,10 @@ export const openAiNativeModels = {
5555
tiers: [
5656
{
5757
name: "flex",
58+
contextWindow: 400000,
5859
inputPrice: 0.125,
5960
outputPrice: 1.0,
60-
cacheReadsPrice: 0.013,
61+
cacheReadsPrice: 0.0125,
6162
},
6263
],
6364
description: "GPT-5 Mini: A faster, more cost-efficient version of GPT-5 for well-defined tasks",
@@ -77,9 +78,10 @@ export const openAiNativeModels = {
7778
tiers: [
7879
{
7980
name: "flex",
81+
contextWindow: 400000,
8082
inputPrice: 0.025,
8183
outputPrice: 0.2,
82-
cacheReadsPrice: 0.003,
84+
cacheReadsPrice: 0.0025,
8385
},
8486
],
8587
description: "GPT-5 Nano: Fastest, most cost-efficient version of GPT-5",

src/api/providers/anthropic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
250250
if (tier) {
251251
info = {
252252
...info,
253-
contextWindow: tier.contextWindow,
253+
contextWindow: tier.contextWindow ?? info.contextWindow,
254254
inputPrice: tier.inputPrice,
255255
outputPrice: tier.outputPrice,
256256
cacheWritesPrice: tier.cacheWritesPrice,

src/api/providers/gemini.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
287287
// If there's tiered pricing then adjust the input and output token prices
288288
// based on the input tokens used.
289289
if (info.tiers) {
290-
const tier = info.tiers.find((tier) => inputTokens <= tier.contextWindow)
290+
const tier = info.tiers.find((tier) => tier.contextWindow && inputTokens <= tier.contextWindow)
291291

292292
if (tier) {
293293
inputPrice = tier.inputPrice ?? inputPrice

0 commit comments

Comments
 (0)