Home › Gemini API lesson 2: Search and JSON
Gemini API lesson 2: Search and JSON
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
- Add tools=[{"type": "google_search"}] to your interactions.create call.
- Show users the sources returned with the grounded answer.
- For JSON, define a schema with Pydantic (Python) or Zod (JavaScript).
- Pass the schema in your request so the reply matches it.
- Use it for data extraction, classification or inputs for other tools.
Try it: examples
- Grounded question
Who won the euro 2024?
- Extraction
Extract the recipe name, prep time in minutes, ingredients with quantities and steps from this text: [paste recipe]
Good to know
- Grounding works in all available languages.
- Structured outputs give predictable, type-safe results, so you don't have to parse free text.
- Check the pricing page for grounding charges before you use it at scale.
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.