Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions packages/types/src/providers/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,47 @@ export const geminiModels = {
supportsReasoningBudget: true,
maxThinkingTokens: 24_576,
},
"gemini-2.5-pro-free": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment block above the free tier models section explaining the mapping strategy and why the -free suffix approach was chosen. This would help future maintainers understand the design decision:

maxTokens: 64_000,
contextWindow: 250_000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 0,
outputPrice: 0,
cacheReadsPrice: 0,
cacheWritesPrice: 0,
maxThinkingTokens: 32_768,
supportsReasoningBudget: true,
requiredReasoningBudget: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that gemini-2.5-pro-free has requiredReasoningBudget: true while the other two free models don't? If free tier models have different reasoning budget requirements, could you clarify why? Otherwise, consider making this consistent across all three free tier models.

description:
"Free tier version of Gemini 2.5 Pro with 250K context window and rate limits (5 RPM, 250K TPM, 100 RPD). Set minimum 12 seconds between requests in provider settings to avoid rate limits.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the rate limit values (5 RPM, 10 RPM, 15 RPM) and recommended delays (12s, 6s, 4s) as constants for better maintainability. This could be useful for potential future rate limiting logic:

},
"gemini-2.5-flash-free": {
maxTokens: 64_000,
contextWindow: 250_000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 0,
outputPrice: 0,
cacheReadsPrice: 0,
cacheWritesPrice: 0,
maxThinkingTokens: 24_576,
supportsReasoningBudget: true,
description:
"Free tier version of Gemini 2.5 Flash with 250K context window and rate limits (10 RPM, 250K TPM, 250 RPD). Set minimum 6 seconds between requests in provider settings to avoid rate limits.",
},
"gemini-2.5-flash-lite-free": {
maxTokens: 64_000,
contextWindow: 250_000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 0,
outputPrice: 0,
cacheReadsPrice: 0,
cacheWritesPrice: 0,
supportsReasoningBudget: true,
maxThinkingTokens: 24_576,
description:
"Free tier version of Gemini 2.5 Flash Lite with 250K context window and rate limits (15 RPM, 250K TPM, 1000 RPD). Set minimum 4 seconds between requests in provider settings to avoid rate limits.",
},
} as const satisfies Record<string, ModelInfo>
10 changes: 9 additions & 1 deletion src/api/providers/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,15 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
// reasoning model and that reasoning is required to be enabled.
// The actual model ID honored by Gemini's API does not have this
// suffix.
return { id: id.endsWith(":thinking") ? id.replace(":thinking", "") : id, info, ...params }
let apiModelId = id.endsWith(":thinking") ? id.replace(":thinking", "") : id

// The `-free` suffix indicates free tier models with rate limits.
// Map them to their corresponding paid models for API calls.
if (apiModelId.endsWith("-free")) {
apiModelId = apiModelId.replace("-free", "") as GeminiModelId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After replacing the "-free" suffix, the resulting string is cast to GeminiModelId without validation. Could this potentially cause runtime errors if the base model doesn't exist? Consider adding validation to ensure the mapped model ID exists in geminiModels:

}

return { id: apiModelId, info, ...params }
}

private extractCitationsOnly(groundingMetadata?: GroundingMetadata): string | null {
Expand Down
Loading