[Python] Unable to integrate with Google Gemini

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    AS a beginner I have started exploring langgraph integrating with Gemini but getting empty response. Tried using python integrating langraph with Gemini-2.5-flashbut the response is empty because. Seems like the langchain is not compatible with gemini-2.5-flash

    old versions are deprecated.

    Please share some code snippets that work with the Gemini model. It will help me learn LangChain and LangGraph.

    Hi, AS a beginner I have started exploring langgraph integrating with Gemini but getting empty response. Below is the code snippet for Langchain, but the response is empty because. Seems like the langchain is not compatible with gemini-2.5-flash

    Please share some code snippets that work with the Gemini model. It will help me learn LangChain and LangGraph.

    =============== Code snippet


    import os from dotenv import load_dotenv from langchain_google_vertexai import VertexAI from google.cloud import aiplatform

    Load .env values into environment variables


    load_dotenv()

    Ensure correct region is used


    aiplatform.init(location="us-central1")

    Confirm that key path is loaded correctly


    print("GOOGLE_APPLICATION_CREDENTIALS =", os.getenv("GOOGLE_APPLICATION_CREDENTIALS"))

    llm = VertexAI(model_name="gemini-2.5-flash", temperature=0.7, max_output_tokens=512)

    response = llm.invoke("Hello from Gemini via Vertex AI") print(response) print("Response type:", type(response))

    ===================== Requirement.txt


    langgraph langgraph-prebuilt langchain langchain-core langchain-community langchain-openai langchain-google-genai google-generativeai python-dotenv google-cloud-aiplatform langchain-google-vertexai

    Continue reading...

Compartilhe esta Página