Home › Gemini API lesson 2: Search and JSON

Gemini API lesson 2: Search and JSON

Last checked

Grounding with Google Search lets Gemini answer about recent events and cite its sources, and structured outputs make it return JSON that matches your schema.

Step by step

  1. Add tools=[{"type": "google_search"}] to your interactions.create call.
  2. Show users the sources returned with the grounded answer.
  3. For JSON, define a schema with Pydantic (Python) or Zod (JavaScript).
  4. Pass the schema in your request so the reply matches it.
  5. Use it for data extraction, classification or inputs for other tools.

Try it: examples

Good to know

Sources (official pages, read Nov 8, 2026)

Written from Google's official documentation and product pages; we don't run hands-on tests. Features and limits vary by plan and country.

Report an error on this page