Repository Public
1# File Search23> [!NOTE]4> **Note** : This version of the page covers the new [Interactions API](https://ai.google.dev/gemini-api/docs/interactions/interactions-overview), which is currently in Beta. 5> For stable production deployments, we recommend you continue to use the `generateContent` API. You can use the toggle on this page to switch between the versions.67The Gemini API enables Retrieval Augmented Generation ("RAG") through the File8Search tool. File Search imports, chunks, and indexes your data to9enable fast retrieval of relevant information based on a provided prompt. This10retrieved information is then used as context for the model, allowing it to11provide more accurate and relevant answers. File search is also able to12provide multimodal capabilities with text embeddings supported by13`gemini-embedding-001`, and image/multimodal embedding supported by `gemini-embedding-2`.1415> [!NOTE]16> **Note:** Audio and video formats are not currently supported.1718File storage and embedding generation at query time is free, and you'll only pay19for creating embeddings when you first index your files and the normal Gemini20model input / output tokens cost. This new billing paradigm makes the File21Search Tool both easier and more cost-effective to build and scale with. See22[pricing](https://ai.google.dev/gemini-api/docs/interactions/file-search#pricing) section for details.2324## Directly upload to File Search store2526This example shows how to directly upload a file to the27[file search store](https://ai.google.dev/api/file-search/file-search-stores#method:-media.uploadtofilesearchstore):2829### Python3031 from google import genai32 from google.genai import types33 import time3435 client = genai.Client()3637 file_search_store = client.file_search_stores.create(38 config={39 'display_name': 'your-fileSearchStore-name',40 'embedding_model': 'models/gemini-embedding-2'41 }42 )4344 operation = client.file_search_stores.upload_to_file_search_store(45 file='sample.txt',46 file_search_store_name=file_search_store.name,47 config={48 'display_name' : 'display-file-name',49 }50 )5152 while not operation.done:53 time.sleep(5)54 operation = client.operations.get(operation)5556 interaction = client.interactions.create(57 model="gemini-3.5-flash",58 input="Can you tell me about [insert question]",59 tools=[{60 "type": "file_search",61 "file_search_store_names": [file_search_store.name]62 }]63 )6465 for step in interaction.steps:66 if step.type == "model_output":67 for content_block in step.content:68 if content_block.type == "text":69 print(content_block.text)70 if content_block.annotations:71 print("\nSources:")72 for annotation in content_block.annotations:73 if annotation.type == "file_citation":74 print(f" - {annotation.file_name}: {annotation.source}")7576### JavaScript7778 const { GoogleGenAI } = require('@google/genai');7980 const ai = new GoogleGenAI({});8182 async function run() {83 const fileSearchStore = await ai.fileSearchStores.create({84 config: {85 displayName: 'your-fileSearchStore-name',86 embeddingModel: 'models/gemini-embedding-2'87 }88 });8990 let operation = await ai.fileSearchStores.uploadToFileSearchStore({91 file: 'file.txt',92 fileSearchStoreName: fileSearchStore.name,93 config: {94 displayName: 'file-name',95 }96 });9798 while (!operation.done) {99 await new Promise(resolve => setTimeout(resolve, 5000));100 operation = await ai.operations.get({ operation });101 }102103 const interaction = await ai.interactions.create({104 model: "gemini-3.5-flash",105 input: "Can you tell me about [insert question]",106 tools: [{107 type: "file_search",108 file_search_store_names: [fileSearchStore.name]109 }]110 });111112 for (const step of interaction.steps) {113 if (step.type === 'model_output') {114 for (const contentBlock of step.content) {115 if (contentBlock.type === 'text') {116 console.log(contentBlock.text);117 if (contentBlock.annotations) {118 console.log("\nSources:");119 for (const annotation of contentBlock.annotations) {120 if (annotation.type === 'file_citation') {121 console.log(` - ${annotation.file_name}: ${annotation.source}`);122 }123 }124 }125 }126 }127 }128 }129 }130131 run();132133Check the API reference for [`uploadToFileSearchStore`](https://ai.google.dev/api/file-search/file-search-stores#method:-media.uploadtofilesearchstore) for more information.134135## Importing files136137Alternatively, you can upload an existing file and [import it to your file search store](https://ai.google.dev/api/file-search/file-search-stores#method:-filesearchstores.importfile):138139### Python140141 from google import genai142 from google.genai import types143 import time144145 client = genai.Client()146147 sample_file = client.files.upload(file='sample.txt', config={'display_name': 'display_file_name'})148149 file_search_store = client.file_search_stores.create(150 config={151 'display_name': 'your-fileSearchStore-name',152 'embedding_model': 'models/gemini-embedding-2'153 }154 )155156 operation = client.file_search_stores.import_file(157 file_search_store_name=file_search_store.name,158 file_name=sample_file.name159 )160161 while not operation.done:162 time.sleep(5)163 operation = client.operations.get(operation)164165 interaction = client.interactions.create(166 model="gemini-3.5-flash",167 input="Can you tell me about [insert question]",168 tools=[{169 "type": "file_search",170 "file_search_store_names": [file_search_store.name]171 }]172 )173174 for step in interaction.steps:175 if step.type == "model_output":176 for content_block in step.content:177 if content_block.type == "text":178 print(content_block.text)179180### JavaScript181182 const { GoogleGenAI } = require('@google/genai');183184 const ai = new GoogleGenAI({});185186 async function run() {187 const sampleFile = await ai.files.upload({188 file: 'sample.txt',189 config: { displayName: 'file-name' }190 });191192 const fileSearchStore = await ai.fileSearchStores.create({193 config: {194 displayName: 'your-fileSearchStore-name',195 embeddingModel: 'models/gemini-embedding-2'196 }197 });198199 let operation = await ai.fileSearchStores.importFile({200 fileSearchStoreName: fileSearchStore.name,201 fileName: sampleFile.name202 });203204 while (!operation.done) {205 await new Promise(resolve => setTimeout(resolve, 5000));206 operation = await ai.operations.get({ operation: operation });207 }208209 const interaction = await ai.interactions.create({210 model: "gemini-3.5-flash",211 input: "Can you tell me about [insert question]",212 tools: [{213 type: "file_search",214 file_search_store_names: [fileSearchStore.name]215 }]216 });217218 for (const step of interaction.steps) {219 if (step.type === 'model_output') {220 for (const contentBlock of step.content) {221 if (contentBlock.type === 'text') {222 console.log(contentBlock.text);223 }224 }225 }226 }227 }228229 run();230231Check the API reference for [`importFile`](https://ai.google.dev/api/file-search/file-search-stores#method:-filesearchstores.importfile) for more information.232233## Chunking configuration234235When you import a file into a File Search store, it's automatically broken down236into chunks, embedded, indexed, and uploaded to your File Search store. If you237need more control over the chunking strategy, you can specify a238[`chunking_config`](https://ai.google.dev/api/file-search/file-search-stores#request-body_5) setting239to set a maximum number of tokens per chunk and maximum number of overlapping240tokens.241242### Python243244 from google import genai245 from google.genai import types246 import time247248 client = genai.Client()249250 operation = client.file_search_stores.upload_to_file_search_store(251 file_search_store_name=file_search_store.name,252 file='sample.txt',253 config={254 'chunking_config': {255 'white_space_config': {256 'max_tokens_per_chunk': 200,257 'max_overlap_tokens': 20258 }259 }260 }261 )262263 while not operation.done:264 time.sleep(5)265 operation = client.operations.get(operation)266267 print("Custom chunking complete.")268269### JavaScript270271 const { GoogleGenAI } = require('@google/genai');272273 const ai = new GoogleGenAI({});274275 let operation = await ai.fileSearchStores.uploadToFileSearchStore({276 file: 'file.txt',277 fileSearchStoreName: fileSearchStore.name,278 config: {279 displayName: 'file-name',280 chunkingConfig: {281 whiteSpaceConfig: {282 maxTokensPerChunk: 200,283 maxOverlapTokens: 20284 }285 }286 }287 });288289 while (!operation.done) {290 await new Promise(resolve => setTimeout(resolve, 5000));291 operation = await ai.operations.get({ operation });292 }293 console.log("Custom chunking complete.");294295To use your File Search store, pass it as a tool to the `interactions.create`296method, as shown in the [Upload](https://ai.google.dev/gemini-api/docs/interactions/file-search#upload) and [Import](https://ai.google.dev/gemini-api/docs/interactions/file-search#importing-files) examples.297298## How it works299300File Search uses a technique called semantic search to find information relevant301to the user prompt. Unlike standard keyword-based search, semantic search302understands the meaning and context of your query.303304When you import a file, it's converted into numerical representations called305[embeddings](https://ai.google.dev/gemini-api/docs/embeddings), which capture the semantic meaning of306the uploaded content. These embeddings are stored in a specialized File Search database.307When you make a query, it's also converted into an embedding. Then the system308performs a File Search to find the most similar and relevant document chunks309from the File Search store.310311There is no Time To Live (TTL) for embeddings;312they persist until manually deleted, or when the model is deprecated. Files,313however, are deleted after 48 hours.314315Here's a breakdown of the process for using the File Search316`uploadToFileSearchStore` API:3173181. **Create a File Search store**: A File Search store contains the processed319 data from your files. It's the persistent container for the embeddings that the320 semantic search will operate on.3213222. **Upload a file and import into a File Search store** : Simultaneously upload323 a file and import the results into your File Search store. This creates a324 temporary `File` object, which is a reference to your raw document. That data is325 then chunked, converted into File Search embeddings, and indexed. The `File`326 object gets deleted after 48 hours, while the data imported into the File Search327 store will be stored indefinitely until you choose to delete it.3283293. **Query with File Search** : Finally, you use the `FileSearch` tool in a330 `generateContent` call. In the tool configuration, you specify a331 `FileSearchRetrievalResource`, which points to the `FileSearchStore` you want to332 search. This tells the model to perform a semantic search on that specific333 File Search store to find relevant information to ground its response.334335 The indexing and querying process of File Search336337In this diagram, the dotted line from *Documents* to *Embedding model*338(using [`gemini-embedding-001`](https://ai.google.dev/gemini-api/docs/embeddings))339represents the `uploadToFileSearchStore` API (bypassing *File storage* ).340Otherwise, using the [Files API](https://ai.google.dev/gemini-api/docs/interactions/files) to separately create341and then import files moves the indexing process from *Documents* to342*File storage* and then to *Embedding model*.343344## File Search stores345346A File Search store is a container for your document embeddings. While raw files347uploaded through the File API are deleted after 48 hours, the data imported into348a File Search store is stored indefinitely until you manually delete it. You can349create multiple File Search stores to organize your documents. The350`FileSearchStore` API lets you create, list, get, and delete to manage your file351search stores. File Search store names are globally scoped.352353Here are some examples of how to manage your File Search stores:354355### Python356357 file_search_store = client.file_search_stores.create(358 config={359 'display_name': 'my-file_search-store-123',360 'embedding_model': 'models/gemini-embedding-2'361 }362 )363364 for file_search_store in client.file_search_stores.list():365 print(file_search_store)366367 my_file_search_store = client.file_search_stores.get(name='fileSearchStores/my-file_search-store-123')368369 client.file_search_stores.delete(name='fileSearchStores/my-file_search-store-123', config={'force': True})370371### JavaScript372373 const fileSearchStore = await ai.fileSearchStores.create({374 config: {375 displayName: 'my-file_search-store-123',376 embeddingModel: 'models/gemini-embedding-2'377 }378 });379380 const fileSearchStores = await ai.fileSearchStores.list();381 for await (const store of fileSearchStores) {382 console.log(store);383 }384385 const myFileSearchStore = await ai.fileSearchStores.get({386 name: 'fileSearchStores/my-file_search-store-123'387 });388389 await ai.fileSearchStores.delete({390 name: 'fileSearchStores/my-file_search-store-123',391 config: { force: true }392 });393394### REST395396 curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \397 -H "Content-Type: application/json" \398 -d '{ "displayName": "My Store", "embedding_model": "models/gemini-embedding-2" }'399400 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \401402 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123?key=${GEMINI_API_KEY}"403404 curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123?key=${GEMINI_API_KEY}"405406## File Search documents407408You can manage individual documents in your file stores with the409[File Search Documents](https://ai.google.dev/api/file-search/documents) API to `list` each document410in a file search store, `get` information about a document, and `delete` a411document by name.412413### Python414415 for document_in_store in client.file_search_stores.documents.list(parent='fileSearchStores/my-file_search-store-123'):416 print(document_in_store)417418 file_search_document = client.file_search_stores.documents.get(name='fileSearchStores/my-file_search-store-123/documents/my_doc')419 print(file_search_document)420421 client.file_search_stores.documents.delete(name='fileSearchStores/my-file_search-store-123/documents/my_doc', config={'force': True})422423### JavaScript424425 const documents = await ai.fileSearchStores.documents.list({426 parent: 'fileSearchStores/my-file_search-store-123'427 });428 for await (const doc of documents) {429 console.log(doc);430 }431432 const fileSearchDocument = await ai.fileSearchStores.documents.get({433 name: 'fileSearchStores/my-file_search-store-123/documents/my_doc'434 });435436 await ai.fileSearchStores.documents.delete({437 name: 'fileSearchStores/my-file_search-store-123/documents/my_doc'438 });439440### REST441442 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123/documents?key=${GEMINI_API_KEY}"443444 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123/documents/my_doc?key=${GEMINI_API_KEY}"445446 curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123/documents/my_doc?key=${GEMINI_API_KEY}&force=true"447448## File metadata449450You can add custom metadata to your files to help filter them or provide451additional context. Metadata is a set of key-value pairs.452453### Python454455 op = client.file_search_stores.import_file(456 file_search_store_name=file_search_store.name,457 file_name=sample_file.name,458 config={459 'custom_metadata': [460 {"key": "author", "string_value": "Robert Graves"},461 {"key": "year", "numeric_value": 1934}462 ]463 }464 )465466### JavaScript467468 let operation = await ai.fileSearchStores.importFile({469 fileSearchStoreName: fileSearchStore.name,470 fileName: sampleFile.name,471 config: {472 customMetadata: [473 { key: "author", stringValue: "Robert Graves" },474 { key: "year", numericValue: 1934 }475 ]476 }477 });478479This is useful when you have multiple documents in a File Search store and want480to search only a subset of them.481482### Python483484 interaction = client.interactions.create(485 model="gemini-3.5-flash",486 input="Tell me about the book 'I, Claudius'",487 tools=[{488 "type": "file_search",489 "file_search_store_names": [file_search_store.name],490 "metadata_filter": 'author="Robert Graves"',491 }]492 )493494 for step in interaction.steps:495 if step.type == "model_output":496 for content_block in step.content:497 if content_block.type == "text":498 print(content_block.text)499500### JavaScript501502 const interaction = await ai.interactions.create({503 model: "gemini-3.5-flash",504 input: "Tell me about the book 'I, Claudius'",505 tools: [{506 type: "file_search",507 file_search_store_names: [fileSearchStore.name],508 metadata_filter: 'author="Robert Graves"',509 }]510 });511512 for (const step of interaction.steps) {513 if (step.type === 'model_output') {514 for (const contentBlock of step.content) {515 if (contentBlock.type === 'text') {516 console.log(contentBlock.text);517 }518 }519 }520 }521522### REST523524 curl "https://generativelanguage.googleapis.com/v1beta/interactions" \525 -H "x-goog-api-key: $GEMINI_API_KEY" \526 -H 'Content-Type: application/json' \527 -H "Api-Revision: 2026-05-20" \528 -X POST \529 -d '{530 "model": "gemini-3.5-flash",531 "input": [{"type": "text", "text": "Tell me about the book I, Claudius"}],532 "tools": [{533 "type": "file_search",534 "file_search_store_names": ["'$STORE_NAME'"],535 "metadata_filter": "author = \"Robert Graves\""536 }]537 }' 2> /dev/null > response.json538539 cat response.json540541Guidance on implementing list filter syntax for `metadata_filter` can be found542at [google.aip.dev/160](https://google.aip.dev/160)543544## Multimodal File Search545546Multimodal File Search lets you to natively embed and search through images,547enabling rich, multimodal RAG applications.548549### Configure the embedding model550551When you create a `FileSearchStore`, you must override the default text-only552embedding model to use a multimodal model. Use `models/gemini-embedding-2` to553process both text and images.554555### Python556557 store = client.file_search_stores.create(558 config={559 "display_name": "Multimodal Catalog",560 "embedding_model": "models/gemini-embedding-2",561 }562 )563564### JavaScript565566 const fileSearchStore = await ai.fileSearchStores.create({567 config: {568 displayName: "Multimodal Catalog",569 embeddingModel: "models/gemini-embedding-2",570 },571 });572573### REST574575 curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=$GEMINI_API_KEY" \576 -H "Content-Type: application/json" \577 -d '{578 "display_name": "Multimodal Catalog",579 "embedding_model": "models/gemini-embedding-2"580 }'581582### Upload images583584After you create the store with a multimodal embedding model, you can upload585image files directly using the same upload APIs described in586[Directly upload to File Search store](https://ai.google.dev/gemini-api/docs/interactions/file-search#upload) or [Importing files](https://ai.google.dev/gemini-api/docs/interactions/file-search#importing-files).587588**Image file requirements:**589590- Image files must be at most 4K x 4K pixels in resolution.591- Supported formats are PNG, JPEG.592593## Citations594595When you use File Search, the model's response may include citations that596specify which parts of your uploaded documents were used to generate the597answer. This helps with fact-checking and verification.598599You can access citation information through the `annotations` attribute inside the `model_output` step's `content` blocks of the response.600601### Python602603 for step in interaction.steps:604 if step.type == 'model_output':605 for content in step.content:606 if content.type == 'text' and content.annotations:607 print(content.annotations)608609### JavaScript610611 for (const step of interaction.steps) {612 if (step.type === 'model_output') {613 for (const contentBlock of step.content) {614 if (contentBlock.type === 'text' && contentBlock.annotations) {615 console.log(JSON.stringify(contentBlock.annotations, null, 2));616 }617 }618 }619 }620621For detailed information on the structure of the citations, see the622[API reference for Interactions](https://ai.google.dev/api/interactions-api#Resource:FileCitation).623624### Page numbers625626When you use File Search with documents that have pages (such as PDFs), the627model's response may include the page number where the information was found.628You can access this information through the `page_number` attribute of a629`file_citation` annotation.630631### Python632633 for step in interaction.steps:634 if step.type == "model_output":635 for content in step.content:636 if content.type == "text" and content.annotations:637 for annotation in content.annotations:638 if annotation.type == "file_citation" and annotation.page_number:639 print(f"Cited Page: {annotation.page_number}")640641### JavaScript642643 for (const step of interaction.steps) {644 if (step.type === 'model_output') {645 for (const block of step.content) {646 if (block.type === 'text' && block.annotations) {647 for (const annotation of block.annotations) {648 if (annotation.type === 'file_citation' && annotation.pageNumber) {649 console.log(`Cited Page: ${annotation.pageNumber}`);650 }651 }652 }653 }654 }655 }656657### Media citations658659When the model references an image chunk during generation, the API returns an660annotation of type `file_citation` in the annotations that includes a `media_id`. You can use this661ID to download the exact image chunk the model referenced. This `media_id` is662persistent across multiple search calls, which lets you reliably retrieve663the same image or cache it using the ID.664665The following snippet is an example REST response step:666667 {668 "type": "model_output",669 "content": [670 {671 "type": "text",672 "text": "...",673 "annotations": [674 {675 "type": "file_citation",676 "file_name": "product_image",677 "media_id": "fileSearchStores/my-store-123/media/BlobId-456"678 }679 ]680 }681 ]682 }683684The following code snippets demonstrate how to retrieve the `media_id` and685download the media:686687### Python688689 for step in interaction.steps:690 if step.type == "model_output":691 for content in step.content:692 if content.type == "text" and content.annotations:693 for annotation in content.annotations:694 if annotation.type == "file_citation" and annotation.media_id:695 print(f"Cited Media ID: {annotation.media_id}")696 blob_content = client.file_search_stores.download_media(697 media_id=annotation.media_id698 )699700### JavaScript701702 for (const step of interaction.steps) {703 if (step.type === 'model_output') {704 for (const block of step.content) {705 if (block.type === 'text' && block.annotations) {706 for (const annotation of block.annotations) {707 if (annotation.type === 'file_citation' && annotation.mediaId) {708 console.log(`Cited Media ID: ${annotation.mediaId}`);709 const blobContent = await ai.fileSearchStores.downloadMedia(annotation.mediaId);710 }711 }712 }713 }714 }715 }716717### REST718719 curl -X GET "https://generativelanguage.googleapis.com/v1/fileSearchStores/my-store-123/media/BlobId-456" \720 -H "x-goog-api-key: $GEMINI_API_KEY"721722## Custom metadata723724If you have added custom metadata to your files, you can access it in the725annotations of the model's response. This is useful for passing726additional context (like URLs, page numbers, or authors) from your source727documents to your application logic. Each citation annotation of type `file_citation`728contains this custom metadata.729730### Python731732 interaction = client.interactions.create(733 model="gemini-3.5-flash",734 input="Tell me about [insert question]",735 tools=[{736 "type": "file_search",737 "file_search_store_names": [file_search_store.name]738 }]739 )740741 for step in interaction.steps:742 if step.type == "model_output":743 for content_block in step.content:744 if content_block.annotations:745 for annotation in content_block.annotations:746 print(annotation)747748### JavaScript749750 const interaction = await ai.interactions.create({751 model: "gemini-3.5-flash",752 input: "Tell me about [insert question]",753 tools: [{754 type: "file_search",755 file_search_store_names: [fileSearchStore.name]756 }]757 });758759 for (const step of interaction.steps) {760 if (step.type === 'model_output') {761 for (const contentBlock of step.content) {762 if (contentBlock.annotations) {763 contentBlock.annotations.forEach((annotation) => {764 console.log(annotation);765 });766 }767 }768 }769 }770771### REST772773 {774 "steps": [775 {776 "type": "model_output",777 "content": [778 {779 "type": "text",780 "text": "...",781 "annotations": [782 {783 "file_name": "...",784 "source": "...",785 "custom_metadata": [786 {787 "key": "author",788 "string_value": "Robert Graves"789 },790 {791 "key": "year",792 "numeric_value": 1934793 }794 ]795 }796 ]797 }798 ]799 }800 ]801 }802803## Structured output804805Starting with Gemini 3 models, you can combine file search tool with806[structured outputs](https://ai.google.dev/gemini-api/docs/interactions/structured-output).807808### Python809810 from pydantic import BaseModel, Field811812 class Money(BaseModel):813 amount: str = Field(description="The numerical part of the amount.")814 currency: str = Field(description="The currency of amount.")815816 interaction = client.interactions.create(817 model="gemini-3.5-flash",818 input="What is the minimum hourly wage in Tokyo right now?",819 tools=[{820 "type": "file_search",821 "file_search_store_names": [file_search_store.name]822 }],823 response_format={824 "type": "text",825 "mime_type": "application/json",826 "schema": Money.model_json_schema()827 },828 )829 result = Money.model_validate_json(interaction.output_text)830 print(result)831832### JavaScript833834 import { z } from "zod";835836 const moneyJsonSchema = {837 type: "object",838 properties: {839 amount: { type: "string", description: "The numerical part of the amount." },840 currency: { type: "string", description: "The currency of amount." }841 },842 required: ["amount", "currency"]843 };844845 const moneySchema = z.fromJSONSchema(moneyJsonSchema);846847 async function run() {848 const interaction = await ai.interactions.create({849 model: "gemini-3.5-flash",850 input: "What is the minimum hourly wage in Tokyo right now?",851 tools: [{852 type: "file_search",853 file_search_store_names: [fileSearchStore.name],854 }],855 response_format: {856 type: 'text',857 mime_type: 'application/json',858 schema: moneyJsonSchema859 },860 });861862 const result = moneySchema.parse(JSON.parse(interaction.output_text));863 console.log(result);864 }865866 run();867868### REST869870 curl "https://generativelanguage.googleapis.com/v1beta/interactions" \871 -H "x-goog-api-key: $GEMINI_API_KEY" \872 -H 'Content-Type: application/json' \873 -H "Api-Revision: 2026-05-20" \874 -X POST \875 -d '{876 "model": "gemini-3.5-flash",877 "input": "What is the minimum hourly wage in Tokyo right now?",878 "tools": [{879 "type": "file_search",880 "file_search_store_names": ["$FILE_SEARCH_STORE_NAME"]881 }],882 "response_format": {883 "type": "text",884 "mime_type": "application/json",885 "schema": {886 "type": "object",887 "properties": {888 "amount": {"type": "string", "description": "The numerical part of the amount."},889 "currency": {"type": "string", "description": "The currency of amount."}890 },891 "required": ["amount", "currency"]892 }893 }894 }'895896## Supported models897898The following models support File Search:899900| Model | File Search |901|---|---|902| [Gemini 3.5 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash) | ✔️ |903| [Gemini 3.1 Pro Preview](https://ai.google.dev/gemini-api/docs/gemini-3.1-pro-preview) | ✔️ |904| [Gemini 3.1 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-lite) | ✔️ |905| [Gemini 3 Flash Preview](https://ai.google.dev/gemini-api/docs/models/gemini-3-flash-preview) | ✔️ |906| [Gemini 2.5 Pro](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-pro) | ✔️ |907| [Gemini 2.5 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-lite) | ✔️ |908909## Supported tool combinations910911Gemini 3 models support combining built-in tools (like File Search) with custom912tools (function calling). Learn more on the913[tool combinations](https://ai.google.dev/gemini-api/docs/tool-combination) page.914915## Supported file types916917File Search supports a wide range of file formats, listed in the following918sections.919920### Application file types921922- `application/dart`923- `application/ecmascript`924- `application/json`925- `application/ms-java`926- `application/msword`927- `application/pdf`928- `application/sql`929- `application/typescript`930- `application/vnd.curl`931- `application/vnd.dart`932- `application/vnd.ibm.secure-container`933- `application/vnd.jupyter`934- `application/vnd.ms-excel`935- `application/vnd.oasis.opendocument.text`936- `application/vnd.openxmlformats-officedocument.presentationml.presentation`937- `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`938- `application/vnd.openxmlformats-officedocument.wordprocessingml.document`939- `application/vnd.openxmlformats-officedocument.wordprocessingml.template`940- `application/x-csh`941- `application/x-hwp`942- `application/x-hwp-v5`943- `application/x-latex`944- `application/x-php`945- `application/x-powershell`946- `application/x-sh`947- `application/x-shellscript`948- `application/x-tex`949- `application/x-zsh`950- `application/xml`951- `application/zip`952953### Text file types954955- `text/1d-interleaved-parityfec`956- `text/RED`957- `text/SGML`958- `text/cache-manifest`959- `text/calendar`960- `text/cql`961- `text/cql-extension`962- `text/cql-identifier`963- `text/css`964- `text/csv`965- `text/csv-schema`966- `text/dns`967- `text/encaprtp`968- `text/enriched`969- `text/example`970- `text/fhirpath`971- `text/flexfec`972- `text/fwdred`973- `text/gff3`974- `text/grammar-ref-list`975- `text/hl7v2`976- `text/html`977- `text/javascript`978- `text/jcr-cnd`979- `text/jsx`980- `text/markdown`981- `text/mizar`982- `text/n3`983- `text/parameters`984- `text/parityfec`985- `text/php`986- `text/plain`987- `text/provenance-notation`988- `text/prs.fallenstein.rst`989- `text/prs.lines.tag`990- `text/prs.prop.logic`991- `text/raptorfec`992- `text/rfc822-headers`993- `text/rtf`994- `text/rtp-enc-aescm128`995- `text/rtploopback`996- `text/rtx`997- `text/sgml`998- `text/shaclc`999- `text/shex`1000- `text/spdx`1001- `text/strings`1002- `text/t140`1003- `text/tab-separated-values`1004- `text/texmacs`1005- `text/troff`1006- `text/tsv`1007- `text/tsx`1008- `text/turtle`1009- `text/ulpfec`1010- `text/uri-list`1011- `text/vcard`1012- `text/vnd.DMClientScript`1013- `text/vnd.IPTC.NITF`1014- `text/vnd.IPTC.NewsML`1015- `text/vnd.a`1016- `text/vnd.abc`1017- `text/vnd.ascii-art`1018- `text/vnd.curl`1019- `text/vnd.debian.copyright`1020- `text/vnd.dvb.subtitle`1021- `text/vnd.esmertec.theme-descriptor`1022- `text/vnd.exchangeable`1023- `text/vnd.familysearch.gedcom`1024- `text/vnd.ficlab.flt`1025- `text/vnd.fly`1026- `text/vnd.fmi.flexstor`1027- `text/vnd.gml`1028- `text/vnd.graphviz`1029- `text/vnd.hans`1030- `text/vnd.hgl`1031- `text/vnd.in3d.3dml`1032- `text/vnd.in3d.spot`1033- `text/vnd.latex-z`1034- `text/vnd.motorola.reflex`1035- `text/vnd.ms-mediapackage`1036- `text/vnd.net2phone.commcenter.command`1037- `text/vnd.radisys.msml-basic-layout`1038- `text/vnd.senx.warpscript`1039- `text/vnd.sosi`1040- `text/vnd.sun.j2me.app-descriptor`1041- `text/vnd.trolltech.linguist`1042- `text/vnd.wap.si`1043- `text/vnd.wap.sl`1044- `text/vnd.wap.wml`1045- `text/vnd.wap.wmlscript`1046- `text/vtt`1047- `text/wgsl`1048- `text/x-asm`1049- `text/x-bibtex`1050- `text/x-boo`1051- `text/x-c`1052- `text/x-c++hdr`1053- `text/x-c++src`1054- `text/x-cassandra`1055- `text/x-chdr`1056- `text/x-coffeescript`1057- `text/x-component`1058- `text/x-csh`1059- `text/x-csharp`1060- `text/x-csrc`1061- `text/x-cuda`1062- `text/x-d`1063- `text/x-diff`1064- `text/x-dsrc`1065- `text/x-emacs-lisp`1066- `text/x-erlang`1067- `text/x-gff3`1068- `text/x-go`1069- `text/x-haskell`1070- `text/x-java`1071- `text/x-java-properties`1072- `text/x-java-source`1073- `text/x-kotlin`1074- `text/x-lilypond`1075- `text/x-lisp`1076- `text/x-literate-haskell`1077- `text/x-lua`1078- `text/x-moc`1079- `text/x-objcsrc`1080- `text/x-pascal`1081- `text/x-pcs-gcd`1082- `text/x-perl`1083- `text/x-perl-script`1084- `text/x-python`1085- `text/x-python-script`1086- `text/x-r-markdown`1087- `text/x-rsrc`1088- `text/x-rst`1089- `text/x-ruby-script`1090- `text/x-rust`1091- `text/x-sass`1092- `text/x-scala`1093- `text/x-scheme`1094- `text/x-script.python`1095- `text/x-scss`1096- `text/x-setext`1097- `text/x-sfv`1098- `text/x-sh`1099- `text/x-siesta`1100- `text/x-sos`1101- `text/x-sql`1102- `text/x-swift`1103- `text/x-tcl`1104- `text/x-tex`1105- `text/x-vbasic`1106- `text/x-vcalendar`1107- `text/xml`1108- `text/xml-dtd`1109- `text/xml-external-parsed-entity`1110- `text/yaml`11111112## Limitations11131114- **Live API:** File Search is not supported in the [Live API](https://ai.google.dev/gemini-api/docs/live).1115- **Tool incompatibility:** File Search cannot be combined with other tools like [Grounding with Google Search](https://ai.google.dev/gemini-api/docs/interactions/google-search), [URL Context](https://ai.google.dev/gemini-api/docs/interactions/url-context), etc. at this time.11161117### Rate limits11181119The File Search API has the following limits to enforce service stability:11201121- **Maximum file size / per document limit**: 100 MB1122- **Total size of project File Search stores** (based on user tier):1123 - **Free**: 1 GB1124 - **Tier 1**: 10 GB1125 - **Tier 2**: 100 GB1126 - **Tier 3**: 1 TB1127- **Recommendation**: Limit the size of each File Search store to under 20 GB to ensure optimal retrieval latencies.11281129> [!NOTE]1130> **Note:** The limit on File Search store size is computed on the backend, based on the size of your input plus the embeddings generated and stored with it. This is typically approximately 3 times the size of your input data.11311132## Pricing11331134- You are charged for embeddings at indexing time based on existing [embeddings pricing](https://ai.google.dev/gemini-api/docs/pricing#gemini-embedding-2).1135- Storage is free of charge.1136- Query time embeddings are free of charge.1137- Retrieved document tokens are charged as regular [context tokens](https://ai.google.dev/gemini-api/docs/interactions/tokens).11381139## What's next11401141- Visit the API reference for [File Search Stores](https://ai.google.dev/api/file-search/file-search-stores) and File Search [Documents](https://ai.google.dev/api/file-search/documents).