A useful AI assistant needs more than a capable model. It also needs reliable access to the information that belongs to a business: product manuals, support policies, technical drawings, training material, contracts, and internal procedures. A large context window alone does not make that information easy to organize or retrieve.
Gemini API File Search is Google's managed retrieval-augmented generation (RAG) tool. It imports files, breaks them into searchable chunks, creates embeddings, and retrieves relevant material when a user asks a question. The multimodal update adds image-aware retrieval through gemini-embedding-2, custom metadata filters, and more precise source citations.
What this guide builds: a small support knowledge base containing a PDF handbook and image-based reference material. A user can ask a natural-language question and receive an answer grounded in the indexed sources, with citation annotations that the application can display or inspect.
What is Gemini API File Search?
File Search is a managed RAG service in the Gemini API. Instead of implementing a separate parser, chunker, embedding pipeline, vector store, and retrieval layer, you create a File Search store and import your documents. Gemini then uses the store as a tool when answering a question.
The May 5, 2026 multimodal update added three useful capabilities:
- Text and image retrieval: use
gemini-embedding-2to index text alongside image content, so a query can find a diagram or photograph by meaning rather than relying only on its filename. - Custom metadata: attach labels such as department, product, document type, or year, then filter retrieval to the relevant subset.
- Source citations: response annotations can identify the file and source material used, including page-level context where available.
Who should use it?
- Support teams: answer policy and troubleshooting questions from manuals, FAQs, and product documentation.
- Developers: search API references, architecture notes, code repositories, and design diagrams.
- Sales and product teams: retrieve details from catalogues, product sheets, comparison charts, and presentation decks.
- Researchers: search across reports, papers, microscopy images, charts, and other mixed-format material.
- Operations teams: build assistants that ground answers in approved procedures and versioned internal documents.
Prerequisites and availability
Before starting, prepare the following:
- A Google AI Studio API key with Gemini API access.
- Python and the official Google Gen AI SDK, or an equivalent supported client.
- A small set of non-sensitive test documents, such as a PDF handbook and a few PNG or JPEG diagrams.
- A clear data owner who can decide which documents may be uploaded, indexed, retained, and queried.
File Search is documented as an available Gemini API capability. The multimodal embedding model is gemini-embedding-2; the current documentation also lists supported generation models, including gemini-3.8-flash and Gemini 4 Argon. Model access, quota, and project limits depend on the account tier. The REST examples use the File Search Store API under the v1beta endpoint, so verify the current API reference before pinning a production integration.
Step 1: Install the Google Gen AI SDK
Install the official Python package in a virtual environment:
pip install -U google-genaiCreate an API key in Google AI Studio and expose it as an environment variable. Do not paste a production key into source code, notebooks committed to Git, or client-side JavaScript.
export GEMINI_API_KEY="YOUR_API_KEY"Step 2: Create a multimodal File Search store
A File Search store is the persistent index that Gemini searches. For a collection containing both documents and images, explicitly select models/gemini-embedding-2. The text-only embedding model does not provide the same image-search behavior.
from google import genai client = genai.Client() store = client.file_search_stores.create( config={"display_name": "support-knowledge-base", "embedding_model": "models/gemini-embedding-2",}) print(store.name)Keep the returned store name in your application's configuration or database. You will need it when importing documents and querying the collection.
Step 3: Upload and index a PDF
For a first test, use a short handbook or product manual. The direct upload method sends the file to the store and starts an indexing operation. The service handles chunking, embedding generation, and indexing.
import time operation = client.file_search_stores.upload_to_file_search_store( file="support-handbook.pdf", file_search_store_name=store.name, config={"display_name": "Support handbook"}, ) while not operation.done: time.sleep(5) operation = client.operations.get(operation) print("Indexing complete")Do not query the store until the indexing operation has completed. For a large import job, record each operation's status and surface failures to an administrator instead of silently treating every upload as successful.
Step 4: Add images and diagrams
Because the store uses gemini-embedding-2, you can upload PNG or JPEG image files using the same File Search upload workflow. This is useful when important information lives in product photographs, architecture diagrams, screenshots, or charts rather than in searchable text.
For example, index a wiring diagram with its accompanying product manual. A user might ask, “Which connector is shown beside the reset switch?” and the retrieval system can search across the indexed text and image content. Always verify visually specific answers against the original image before presenting them as authoritative instructions.
Step 5: Attach metadata to keep results organized
Metadata helps separate documents that share similar wording. You could label files by department, product family, document status, or year. The official SDK supports custom metadata during file import:
uploaded_file = client.files.upload( file="returns-policy.pdf", config={"display_name": "Returns policy"}) operation = client.file_search_stores.import_file( file_search_store_name=store.name, file_name=uploaded_file.name, config={"custom_metadata": [{"key": "department", "string_value": "support"},{"key": "status", "string_value": "approved"},{"key": "year", "numeric_value": 2026}, ]})When querying, you can apply a metadata filter such as department="support". This narrows the retrieval scope and helps avoid mixing draft material with approved policies. Establish a consistent metadata vocabulary before importing thousands of files.
Step 6: Ask a question and inspect citations
Pass the store name to the File Search tool in a Gemini interaction. The following example uses gemini-3.8-flash, which appears in the current File Search supported-model table.
interaction = client.interactions.create( model="gemini-3.8-flash", input="What is the refund window for annual plans? Cite the source.", tools=[{"type": "file_search", "file_search_store_names": [store.name],}], ) for step in interaction.steps: if step.type == "model_output": for block in step.content: if block.type == "text": print(block.text) if block.annotations: for annotation in block.annotations: if annotation.type == "file_citation": print(annotation.file_name, annotation.source)In a production application, parse the citation annotations and render them beside the answer. Keep the original file available to authorized users so they can verify the cited passage, page, or image. A citation is evidence of retrieved context, not proof that the generated answer is correct.
Step 7: Evaluate retrieval before launch
Prepare a test set of questions whose answers are known. Include questions that require exact values, similar product names, old and new policy versions, image interpretation, and questions for which the correct response is “not found.”
- Check whether the expected document appears in the retrieved citations.
- Confirm that the answer matches the cited source rather than an outdated or conflicting document.
- Test metadata filters to make sure draft, archived, or unrelated records are excluded.
- Ask questions that are not answered by the corpus and verify that the application can say it does not have enough evidence.
- Review latency, token usage, indexing failures, and the cost of re-indexing updated files.
Costs, quotas, and data retention
Google's current File Search documentation says storage and query-time embedding generation are free. Embedding creation at indexing time is billed at the selected embedding model's rate, and retrieved document tokens are charged as normal Gemini context input. The generation model's input and output tokens are also billed according to its pricing tier.
The published limits currently include:
- Maximum document size: 100 MB per file.
- Project store capacity: 1 GB on the Free tier, 10 GB on Tier 1, 100 GB on Tier 2, and 1 TB on Tier 3.
- Recommended store size: keep an individual store below 20 GB where possible for better retrieval latency.
- Image requirements: PNG and JPEG images up to 4K by 4K pixels.
There is an important retention distinction: the temporary raw File API object is deleted after 48 hours, while the indexed data in a File Search store remains until you delete it or the embedding model is deprecated. Plan document deletion, retention, access controls, and re-indexing as part of your data-governance process.
Limitations to understand
- Audio and video formats are not currently supported by File Search.
- File Search is not supported in the Gemini Live API.
- Built-in grounding tools cannot all be combined in one request; for example, File Search cannot be used in the same request as Grounding with Google Search or URL Context.
- Retrieval can miss relevant material, and generated answers can still be wrong. Use evaluation questions and human review for legal, financial, medical, or safety-critical content.
- Files are processed in Google's cloud. This is not a local-only or on-premises indexing system; confirm that your organization's data policies permit the upload.
Frequently asked questions
Does Gemini File Search work with images?
Yes. Create the store with models/gemini-embedding-2 and upload supported PNG or JPEG images. The current documentation specifies a maximum image resolution of 4K by 4K pixels.
Does File Search support video or audio?
No. The current File Search documentation says audio and video formats are not supported. Use a separate transcription or media-processing workflow if those formats are part of your knowledge base.
Do I pay every time the system searches my store?
Google says storage and query-time embeddings are free. You still pay for retrieved context tokens and the normal Gemini model input and output tokens. Initial embedding creation is billed at indexing time.
Are uploaded files stored permanently?
The temporary raw File API object is deleted after 48 hours. The indexed data in the File Search store persists until you manually delete it or the embedding model is deprecated.
Can I use File Search with Google Search grounding in the same request?
Not in the same request according to the current tool-compatibility documentation. File Search and built-in grounding tools such as Google Search or URL Context cannot be combined together in one request.
Practical takeaways
- Use
gemini-embedding-2when your knowledge base contains both text and images. - Organize stores by business domain and apply consistent metadata to every imported document.
- Render source citations and preserve a path to the original document for verification.
- Budget for indexing and model tokens, even though storage and query-time embeddings are free.
- Delete outdated indexed documents deliberately; deleting the temporary upload object does not remove the persistent index.
Official sources and further reading
- Google AI for Developers: Gemini API File Search documentation (updated October 13, 2026)
- Google: Gemini API File Search is now multimodal (May 5, 2026)
- Google AI for Developers: Gemini API pricing
- Google Gen AI Python SDK
Conclusion
Gemini API File Search can shorten the path from a folder of mixed documents to a grounded AI assistant. Its multimodal embeddings, metadata filters, and citation annotations are useful building blocks, but they do not remove the need for good document hygiene, access control, testing, and human verification. Start with a small approved corpus, measure retrieval quality, and expand only after the answers can be traced back to the right sources.
