Links not included when asked for .(with grounding)

export const chatGenAiModel = genAI.getGenerativeModel({model:“gemini-2.0-flash”, tools:[{‘google_search’: {}}]})
const generationConfig = {

  • temperature: 1,*
  • topP: 0.95,*
  • topK: 40,*
  • maxOutputTokens: 8192,*
  • responseMimeType: “text/plain”,*
    };

async function run() {

  • const chatSession = chatGenAiModel.startChat({*

  • generationConfig,*

  • });*

  • const result = await chatSession.sendMessage(“find me latest videos on binary search”);*

  • console.log(result.response.text());*
    }

Log output–*

Computerphile: “Binary Search Algorithm” published on November 1, 2023, explains the basics of binary search with Dr. Mike Pound. *
** Milan Jovanovic: “Binary Search Algorithm in C#” published on September 17, 2024, covers a practical example, whiteboard explanation, C# implementation, real-world use cases, and performance benchmarks.

** Apna College: “Binary Search Algorithm - Iterative and Recursive Method | [Theory + Code] with Example” published on September 26, 2024, explains the theory and code with examples for both iterative and recursive methods.*

why the model not using the grounding vertex links and crafting response with those links

when used in ai studio it works fine , does they do some processing in the frontend like extracting links from grounding meta data and then concat with response??

Hi @Rajveer_Singh,

My guess is you are asking only for text from the response. Can you follow this doc and use this “console.log(result.response.candidates[0].groundingMetadata);” and let see if this resolves your issue.

Thanks.