Skip to content

feat(ai-gemini): add support for Gemini 3.1 Flash Lite Preview model#351

Open
NachoVazquez wants to merge 3 commits intoTanStack:mainfrom
naxodev:feature/add-gemini-3.1-flash-lite
Open

feat(ai-gemini): add support for Gemini 3.1 Flash Lite Preview model#351
NachoVazquez wants to merge 3 commits intoTanStack:mainfrom
naxodev:feature/add-gemini-3.1-flash-lite

Conversation

@NachoVazquez
Copy link

@NachoVazquez NachoVazquez commented Mar 8, 2026

🎯 Changes

Added support for Gemini 3.1 Flash Lite Preview model to the @tanstack/ai-gemini adapter.

Model Details

  • Model ID: gemini-3.1-flash-lite-preview
  • Description: Google's fastest and most cost-efficient Gemini 3 series model
  • Pricing: $0.25/1M input tokens, $1.50/1M output tokens
  • Capabilities: Full multimodal support (text, image, audio, video, document), thinking, structured output, function calling, code execution, caching, batch API, search grounding
  • Token Limits: 1,048,576 input tokens, 65,536 output tokens

Files Changed

  • packages/typescript/ai-gemini/src/model-meta.ts: Added GEMINI_3_1_FLASH_LITE_PREVIEW model constant with full specifications, added to GEMINI_MODELS array and type maps (GeminiChatModelProviderOptionsByName, GeminiModelInputModalitiesByName)
  • packages/typescript/ai-gemini/src/adapters/summarize.ts: Added gemini-3.1-flash-lite-preview to GeminiSummarizeModels array
  • packages/typescript/ai-gemini/tests/model-meta.test.ts: Added comprehensive type assertion tests for the new model (thinking support, provider options, property checks, input modalities)
  • .changeset/fluffy-rats-worry.md: Generated changeset for release

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features
    • Added support for the Gemini 3.1 Flash Lite Preview model with full multimodal capabilities (text, image, audio, video, and document inputs).
    • Integrated thinking and structured output options for the new model.
    • Enabled the new model for summarization tasks.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 10707eda-0220-4edf-81d3-0a7338e2c3a7

📥 Commits

Reviewing files that changed from the base of the PR and between 2e8a978 and e982818.

📒 Files selected for processing (4)
  • .changeset/fluffy-rats-worry.md
  • packages/typescript/ai-gemini/src/adapters/summarize.ts
  • packages/typescript/ai-gemini/src/model-meta.ts
  • packages/typescript/ai-gemini/tests/model-meta.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/fluffy-rats-worry.md
  • packages/typescript/ai-gemini/src/adapters/summarize.ts

📝 Walkthrough

Walkthrough

This change introduces support for the Gemini 3.1 Flash Lite Preview model to the AI-Gemini adapter. The model is registered in metadata with specifications for tokens, pricing, capabilities, and added to the summarization adapter. Comprehensive type tests verify full multimodal support and configuration options.

Changes

Cohort / File(s) Summary
Model Registration
packages/typescript/ai-gemini/src/model-meta.ts, packages/typescript/ai-gemini/src/adapters/summarize.ts
Added GEMINI_3_1_FLASH_LITE constant with token limits, pricing ($0.25/$1.50 per 1M tokens), and capabilities. Registered in GEMINI_MODELS and GeminiChatModelProviderOptionsByName maps. Added model name to GeminiSummarizeModels for summarization support.
Model Type Definitions
packages/typescript/ai-gemini/src/model-meta.ts
Extended GeminiModelInputModalitiesByName to include input modality typing for the new model, supporting all content types (text, image, audio, video, document).
Type Tests & Verification
packages/typescript/ai-gemini/tests/model-meta.test.ts
Added comprehensive type-level assertions verifying thinking options, structured output capabilities, safety settings, tool configuration, cached content support, and full multimodal input support for gemini-3.1-flash-lite-preview.
Changeset Documentation
.changeset/fluffy-rats-worry.md
Added changeset entry documenting the minor version bump introducing Gemini 3.1 Flash Lite Preview with full feature support and specifications.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A speedy model hops into view,
With flash-like speed and tokens to pursue,
Three-point-one lighter, but never less strong,
Multimodal thinking all day long,
The Gemini family grows ever true! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(ai-gemini): add support for Gemini 3.1 Flash Lite Preview model' accurately summarizes the main change: adding a new model to the Gemini adapter.
Description check ✅ Passed The description follows the template structure with completed 🎯 Changes section, checked ✅ Checklist items, and marked 🚀 Release Impact including changeset generation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/typescript/ai-gemini/src/adapters/summarize.ts (1)

23-29: ⚠️ Potential issue | 🔴 Critical

Update gemini-3.1-flash-lite to gemini-3.1-flash-lite-preview.

The model identifier in this array does not match the official Gemini API documentation. The Gemini API publishes this model as gemini-3.1-flash-lite-preview, and API calls using the identifier without the -preview suffix will fail. Additionally, this inconsistency should be corrected in model-meta.ts where GEMINI_3_1_FLASH_LITE is defined, as all other Gemini 3.x models in that file include the -preview suffix.

🔧 Minimal fix
 export const GeminiSummarizeModels = [
-  'gemini-3.1-flash-lite',
+  'gemini-3.1-flash-lite-preview',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/typescript/ai-gemini/src/adapters/summarize.ts` around lines 23 -
29, Update the Gemini model identifier strings to match the official API:
replace 'gemini-3.1-flash-lite' with 'gemini-3.1-flash-lite-preview' in the
GeminiSummarizeModels array and also update the corresponding constant
GEMINI_3_1_FLASH_LITE in model-meta.ts to include the '-preview' suffix so all
Gemini 3.x entries are consistent with the API.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/typescript/ai-gemini/src/model-meta.ts`:
- Around line 231-266: Update the GEMINI_3_1_FLASH_LITE model definition so its
name property uses the published ID "gemini-3.1-flash-lite-preview" instead of
"gemini-3.1-flash-lite", and then search for and update any hardcoded references
to the old ID in the summarize adapter and related tests to the new ID (ensure
the constant GEMINI_3_1_FLASH_LITE and its type assertion/satisfies clause
remain unchanged except for the name string).

---

Outside diff comments:
In `@packages/typescript/ai-gemini/src/adapters/summarize.ts`:
- Around line 23-29: Update the Gemini model identifier strings to match the
official API: replace 'gemini-3.1-flash-lite' with
'gemini-3.1-flash-lite-preview' in the GeminiSummarizeModels array and also
update the corresponding constant GEMINI_3_1_FLASH_LITE in model-meta.ts to
include the '-preview' suffix so all Gemini 3.x entries are consistent with the
API.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4807662e-6a0e-4986-b1f2-ffb4a594e83a

📥 Commits

Reviewing files that changed from the base of the PR and between 7c7832e and cbaccd7.

📒 Files selected for processing (3)
  • packages/typescript/ai-gemini/src/adapters/summarize.ts
  • packages/typescript/ai-gemini/src/model-meta.ts
  • packages/typescript/ai-gemini/tests/model-meta.test.ts

@NachoVazquez NachoVazquez force-pushed the feature/add-gemini-3.1-flash-lite branch from cbaccd7 to 43a0f1f Compare March 8, 2026 04:00
@NachoVazquez NachoVazquez requested a review from a team March 8, 2026 04:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/pull_request_template.md:
- Line 16: Update the PR description entry that currently reads
".changeset/flat-dingos-fry.md" to reference the actual changeset filename in
this PR ".changeset/fluffy-rats-worry.md" so the listed changeset matches the
file included; locate the offending string in the PR description or template and
replace it with the correct filename.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a22bb7d-58c8-469b-975e-37864931678c

📥 Commits

Reviewing files that changed from the base of the PR and between cbaccd7 and 43a0f1f.

📒 Files selected for processing (5)
  • .changeset/fluffy-rats-worry.md
  • .github/pull_request_template.md
  • packages/typescript/ai-gemini/src/adapters/summarize.ts
  • packages/typescript/ai-gemini/src/model-meta.ts
  • packages/typescript/ai-gemini/tests/model-meta.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/typescript/ai-gemini/src/adapters/summarize.ts

@NachoVazquez NachoVazquez changed the title feat: add support for gemini 3.1 flash-lite feat(ai-gemini): add support for Gemini 3.1 Flash Lite Preview model Mar 8, 2026
Add the new Gemini 3.1 Flash Lite Preview model to the Gemini adapter with full
multimodal support and comprehensive type safety.

Model Specifications:
- Model ID: gemini-3.1-flash-lite-preview
- Input tokens: 1,048,576
- Output tokens: 65,536
- Knowledge cutoff: 2025-01-01
- Pricing: $0.25/1M input, $1.50/1M output

Capabilities:
- Full multimodal input: text, image, audio, video, document
- Thinking and structured output support
- Function calling and code execution
- Caching, batch API, search grounding, URL context
- Available for summarization tasks

Changes:
- Add GEMINI_3_1_FLASH_LITE model constant to model-meta.ts
- Add model to GEMINI_MODELS array and type maps
- Add to GeminiSummarizeModels for summarization support
- Add comprehensive type assertion tests (33 total tests)
- Create changeset for minor version release

All tests pass: test:types, test:eslint, test:lib, test:pr
@NachoVazquez NachoVazquez force-pushed the feature/add-gemini-3.1-flash-lite branch from 2e8a978 to e982818 Compare March 8, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant