-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add Gemini free tier models with -free aliases #7361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -295,4 +295,47 @@ export const geminiModels = { | |
| supportsReasoningBudget: true, | ||
| maxThinkingTokens: 24_576, | ||
| }, | ||
| "gemini-2.5-pro-free": { | ||
| 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, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it intentional that gemini-2.5-pro-free has |
||
| 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.", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
|
||
There was a problem hiding this comment.
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: