langchain - ✅(Solved) Fix Support for gemini-3.1-flash-lite-preview and gemini-3-flash-preview from Google AI Studio [1 pull requests, 3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#35571Fetched 2026-04-08 00:25:31
View on GitHub
Comments
3
Participants
3
Timeline
9
Reactions
0
Timeline (top)
commented ×3labeled ×2cross-referenced ×1issue_type_added ×1

Fix Action

Fixed

PR fix notes

PR #1628: fix(genai): add missing profile for gemini-3.1-flash-lite-preview

Description (problem / solution / changelog)

Description

gemini-3.1-flash-lite-preview was missing from _profiles.py in both langchain-google-genai and langchain-google-vertexai packages.

This caused self.profile to resolve to an empty {}, meaning tool_calling, tool_choice, and reasoning_output all fell back to incorrect defaults — breaking tool use and structured output for this model.

Profile values verified against Google AI official docs:

  • 1M token input context window
  • 64K max output tokens
  • Full multimodal inputs (text, image, audio, video, pdf)
  • Reasoning/thinking support
  • Tool calling and structured output support

Relevant issues

Related to langchain-ai/langchain#35571

Type

🐛 Bug Fix

Changes

  • Added profile entry for gemini-3.1-flash-lite-preview to:
    • libs/genai/langchain_google_genai/data/_profiles.py
    • libs/vertexai/langchain_google_vertexai/data/_profiles.py

Testing

  • 252 unit tests passing (uv run --group test pytest tests/unit_tests/)
  • ruff linter passing (ruff check . — all checks passed, 34 files formatted)
  • Capabilities verified against Google AI official docs

Note

Profile values follow the same pattern as the sibling model gemini-3-flash-preview which is already present in both files. Manual profile updates follow the pattern established in #1601.

Changed files

  • libs/genai/langchain_google_genai/data/_profiles.py (modified, +19/-0)
  • libs/vertexai/langchain_google_vertexai/data/_profiles.py (modified, +19/-0)
RAW_BUFFERClick to expand / collapse

Checked other resources

  • This is a feature request, not a bug report or usage question.
  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-community package.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Feature Description

I tried reading images with gemini-3.1-flash-lite-preview and gemini-3-flash-preview using the API from Google AI Studio and observed that the output of response.content is actually a list, not a str like model gemini-2.5-flash

Use Case

I'm trying to read images with gemini. If the output format of response.content is not a str, I think it's gonna affect the llm.with_structured_output too (even though I haven't tested it yet). Please support it.

Proposed Solution

Currently I need to implement a helper function to parse the response.content. If it a str, then go to normal workflow. If it's a list, then go to get text field of the dict in the list.

Alternatives Considered

No response

Additional Context

The package that I was testing with is langchain-google-genai==3.0.0

extent analysis

Solution Plan

Fix Name

Support response.content as a list in langchain-google-genai

Fix Steps

1. Update langchain-google-genai package

Update the langchain-google-genai package to the latest version, which should support response.content as a list.

pip install --upgrade langchain-google-genai

2. Modify the API call to handle list output

Update the API call to check if response.content is a list and extract the text field from the dictionary if it is.

import langchain

# Create an LLM instance
llm = langchain.llms.GoogleGenAI()

# Define a function to handle list output
def handle_list_output(response):
    if isinstance(response.content, list):
        return response.content[0].get('text', '')
    return response.content

# Make the API call
response = llm.call(query="Read this image")

# Handle the output
output = handle_list_output(response)

3. Test the updated code

Test the updated code to ensure it handles both string and list outputs correctly.

import unittest

class TestLangchainGoogleGenAI(unittest.TestCase):
    def test_string_output(self):
        # Test with string output
        response = llm.call(query="Read this text")
        self.assertIsInstance(response.content, str)

    def test_list_output(self):
        # Test with list output
        response = llm.call(query="Read this image")
        self.assertIsInstance(response.content, list)
        self.assertIsInstance(response.content[0], dict)
        self.assertIn('text', response.content[0])

if __name__ == '__main__':
    unittest.main()

Verification

To verify that the fix worked, run the test cases and ensure that they pass without any errors. You can also manually test the code by making API calls with different inputs and checking

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING