AI / Google Antigravity Gemini Fundamentals Interview Questions
What is the Gemini API's grounded generation with Google Search and how does attribution work?
When Search Grounding is enabled, Gemini not only uses real-time web data to improve its response but also returns grounding metadata - source attributions showing which web pages contributed to the answer. This enables you to display proper citations in your application.
from google import genai from google.genai import types client = genai.Client() response = client.models.generate_content( model="gemini-3.5-flash", contents="What are the most recent Gemini API updates?", config=types.GenerateContentConfig( tools=[types.Tool(google_search=types.GoogleSearch())], ) ) print(response.text) # Access grounding metadata: candidate = response.candidates[0] if candidate.grounding_metadata: gm = candidate.grounding_metadata # Sources used: print("\nSources:") for chunk in gm.grounding_chunks: if chunk.web: print(f" - {chunk.web.title}: {chunk.web.uri}") # Which parts of the response are grounded: for support in gm.grounding_supports: text_segment = support.segment.text sources = [gm.grounding_chunks[i].web.uri for i in support.grounding_chunk_indices] print(f"\nClaim: {text_segment[:80]}...") print(f"Supported by: {sources}") # Search entry point (rendered search suggestion UI element): if gm.search_entry_point: print(f"\nSearch UI: {gm.search_entry_point.rendered_content[:100]}")
The grounding_supports array maps specific text segments in the response to the sources that support them - enabling you to render inline citations (like footnotes) in your UI. The search_entry_point contains a rendered HTML element that displays a Google Search suggestion, which some applications are required to show.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
