Every agent in this codelab reads its configuration from environment variables at startup. Setting these variables correctly — particularlyDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/derailed-dash/gemini-file-search-demo/llms.txt
Use this file to discover all available pages before exploring further.
GEMINI_API_KEY — is a prerequisite for running any of the SDK or ADK agents. This page walks you through obtaining an API key, creating your .env file, and loading the variables into your shell.
Environment variables
| Variable | Required | Default | Description |
|---|---|---|---|
GEMINI_API_KEY | Yes | — | Your Gemini API key from Google AI Studio. The SDK reads this automatically via genai.Client(). |
MODEL | No | gemini-2.5-flash | The Gemini model ID to use across all agents. |
STORE_NAME | No | demo-file-store | The display name of the File Search Store to attach to RAG agents. Must match the name you used when creating the store in the notebook. |
Getting a Gemini API key
The Gemini File Search tool requires the Gemini Developer API, which uses an API key rather than service-account credentials.Open Google AI Studio
Go to Google AI Studio and sign in with your Google account.
Create an API key
Follow the steps in the API key guide to generate a key for your Google Cloud project.
Creating your .env file
The repository ships with .env.template as a starting point. Copy it to .env and fill in your values.
Edit the file
Open Replace
.env in your editor. The template contains:your-api-key with your actual Gemini API key. Adjust MODEL and STORE_NAME if needed..env is listed in .gitignore. Never commit a file containing a real API key to version control.What happens when STORE_NAME is not set or the store is not found
Both sdk_rag_agent.py and rag_agent_adk/agent.py perform a graceful fallback rather than crashing when the File Search Store is unavailable.
-
If
STORE_NAMEis not set at all, the agents log:and disable RAG capabilities for that session. -
If
STORE_NAMEis set but no store with that display name exists, the agents log:and continue running without the File Search tool attached.
MODEL variable
All agents fall back to gemini-2.5-flash when MODEL is not set. To use a different model, set the variable before sourcing:
The model must support the tools you intend to use. File Search and Google Search are supported on current Gemini 2.x models. If you see a “model not found” error, verify the model ID is correct.