Back to Agno

Gemini 3 -- Build Agents with Google Gemini

cookbook/gemini_3/README.md

2.6.46.8 KB
Original Source

Gemini 3 -- Build Agents with Google Gemini

Build Agno agents with Google Gemini, progressively adding capabilities at each step. From a basic chat to workflows and multi-agent teams deployed on Agent OS.

This guide walks through the basics of building Agents, the easy way. Follow along to learn how to build agents with tools, storage, memory, knowledge, state, guardrails, and human in the loop. We'll also build multi-agent teams and step-based agentic workflows.

Each example can be run independently and contains detailed comments + example prompts to help you understand what's happening behind the scenes. We'll use Gemini 3 Flash — fast, affordable, and excellent at tool calling but you can swap in any model with a one line change. We use either Gemini 3 Flash or Gemini 3.1 Pro as the model, depending on the example.

Fast Path

bash
# 1. Clone
git clone https://github.com/agno-agi/agno.git && cd agno

# 2. Create virtual environment
uv venv .venvs/gemini --python 3.12 && source .venvs/gemini/bin/activate

# 3. Install
uv pip install -r cookbook/gemini_3/requirements.txt

# 4. Set your API key
export GOOGLE_API_KEY=your-google-api-key

# 5. Run your first agent
python cookbook/gemini_3/1_basic.py

What You'll Build

Part 1: Framework Basics

#FileAgentWhat It AddsKey Features
11_basic.pyChat AssistantAgent + Gemini, sync/async/streamingAgent, print_response, streaming
22_tools.pyFinance AgentWebSearchTools, instructionsTool calling, system prompts
33_structured_output.pyMovie CriticPydantic output_schemaStructured output, type safety

Part 2: Gemini-Native Features

#FileAgentWhat It AddsKey Features
44_search.pyNews AgentGemini native searchReal-time Google Search
55_grounding.pyFact CheckerGrounding with citationsVerifiable, cited responses
66_url_context.pyURL Context AgentNative URL fetchingRead and compare web pages
77_thinking.pyThinking AgentExtended thinking with budgetComplex reasoning, chain-of-thought

Part 3: Multimodal

#FileAgentWhat It AddsKey Features
88_image_input.pyImage AnalystImage understandingDescribe, read text, answer questions
99_image_generation.pyImage GeneratorImage generation + editingCreate and edit images from text
1010_audio_input.pyAudio AnalystAudio transcriptionTranscribe, summarize, analyze
1111_text_to_speech.pyTTS AgentText-to-speech audio outputGenerate spoken audio
1212_video_input.pyVideo AnalystVideo understanding + YouTubeScene description, content analysis
1313_pdf_input.pyDocument ReaderPDF understandingRead documents natively
1414_csv_input.pyData AnalystCSV analysisAnalyze datasets directly

Part 4: Advanced Features

#FileAgentWhat It AddsKey Features
1515_file_search.pyFile Search AgentServer-side RAG with citationsManaged document search
1616_prompt_caching.pyTranscript AnalystPrompt caching for token savingsCache large documents

Part 5: Knowledge, Memory, Team, and Workflow

#FileAgentWhat It AddsKey Features
1717_knowledge.pyRecipe AssistantChromaDb knowledge + SqliteDb storageLocal RAG, hybrid search
1818_memory.pyPersonal TutorLearningMachine + agentic memoryAgent improves over time
1919_team.pyContent TeamMulti-agent team (Writer/Editor/Fact-Checker)Team coordination
2020_workflow.pyResearch PipelineStep-based workflow (Parallel, Condition)Predictable multi-step pipelines
2121_agent_os.pyAgent OSAll agents + team + workflow on Agent OSWeb UI, tracing, deployment

Run Each Step

bash
# Part 1: Framework Basics
python cookbook/gemini_3/1_basic.py              # Basic chat
python cookbook/gemini_3/2_tools.py              # Agent + tools
python cookbook/gemini_3/3_structured_output.py  # Structured output

# Part 2: Gemini Features
python cookbook/gemini_3/4_search.py             # Native search
python cookbook/gemini_3/5_grounding.py          # Grounding
python cookbook/gemini_3/6_url_context.py        # URL context fetching
python cookbook/gemini_3/7_thinking.py           # Extended thinking

# Part 3: Multimodal
python cookbook/gemini_3/8_image_input.py        # Image understanding
python cookbook/gemini_3/9_image_generation.py   # Image generation + editing
python cookbook/gemini_3/10_audio_input.py       # Audio understanding
python cookbook/gemini_3/11_text_to_speech.py    # Text-to-speech
python cookbook/gemini_3/12_video_input.py       # Video + YouTube
python cookbook/gemini_3/13_pdf_input.py         # PDF understanding
python cookbook/gemini_3/14_csv_input.py         # CSV analysis

# Part 4: Advanced Features
python cookbook/gemini_3/15_file_search.py       # Server-side RAG
python cookbook/gemini_3/16_prompt_caching.py    # Prompt caching

# Part 5: Production
python cookbook/gemini_3/17_knowledge.py         # Knowledge + storage
python cookbook/gemini_3/18_memory.py            # Memory + learning
python cookbook/gemini_3/19_team.py              # Multi-agent team
python cookbook/gemini_3/20_workflow.py           # Step-based workflow
python cookbook/gemini_3/21_agent_os.py          # Agent OS (web UI)

Run via Agent OS

Agent OS provides a web interface for interacting with all your agents. Step 21 registers every agent, team, and workflow from this guide.

bash
python cookbook/gemini_3/21_agent_os.py

Then visit os.agno.com and add http://localhost:7777 as an endpoint.

Troubleshooting

IssueFix
GOOGLE_API_KEY not setexport GOOGLE_API_KEY=your-key
ModuleNotFoundErroruv pip install -r cookbook/gemini_3/requirements.txt
429 Rate limit exceededWait a minute, or use a different model ID
Model not foundCheck model ID spelling -- use gemini-3-flash-preview or gemini-3.1-pro-preview

Learn More