Repository Public
1The Gemini API enables Retrieval Augmented Generation ("RAG") through the File2Search tool. File Search imports, chunks, and indexes your data to3enable fast retrieval of relevant information based on a provided prompt. This4retrieved information is then used as context for the model, allowing it to5provide more accurate and relevant answers. File search is also able to6provide multimodal capabilities with text embeddings supported by7`gemini-embedding-001`, and image/multimodal embedding supported by `gemini-embedding-2`.89> [!NOTE]10> **Note:** Audio and video formats are not currently supported.1112File storage and embedding generation at query time is free, and you'll only pay13for creating embeddings when you first index your files and the normal Gemini14model input / output tokens cost. This new billing paradigm makes the File15Search Tool both easier and more cost-effective to build and scale with. See16[pricing](https://ai.google.dev/gemini-api/docs/generate-content/file-search#pricing) section for details.1718## Directly upload to File Search store1920This example shows how to directly upload a file to the [file search store](https://ai.google.dev/api/file-search/file-search-stores#method:-media.uploadtofilesearchstore):2122### Python2324 from google import genai25 from google.genai import types26 import time2728 client = genai.Client()2930 # File name will be visible in citations31 file_search_store = client.file_search_stores.create(32 config={33 'display_name': 'your-fileSearchStore-name',34 'embedding_model': 'models/gemini-embedding-2'35 }36 )3738 operation = client.file_search_stores.upload_to_file_search_store(39 file='sample.txt',40 file_search_store_name=file_search_store.name,41 config={42 'display_name' : 'display-file-name',43 }44 )4546 while not operation.done:47 time.sleep(5)48 operation = client.operations.get(operation)4950 response = client.models.generate_content(51 model="gemini-3.8-flash",52 contents="""Can you tell me about [insert question]""",53 config=types.GenerateContentConfig(54 tools=[55 types.Tool(56 file_search=types.FileSearch(57 file_search_store_names=[file_search_store.name]58 )59 )60 ]61 )62 )6364 print(response.text)6566### JavaScript6768 const { GoogleGenAI } = require('@google/genai');6970 const ai = new GoogleGenAI({});7172 async function run() {73 // File name will be visible in citations74 const fileSearchStore = await ai.fileSearchStores.create({75 config: {76 displayName: 'your-fileSearchStore-name',77 embeddingModel: 'models/gemini-embedding-2'78 }79 });8081 let operation = await ai.fileSearchStores.uploadToFileSearchStore({82 file: 'file.txt',83 fileSearchStoreName: fileSearchStore.name,84 config: {85 displayName: 'file-name',86 }87 });8889 while (!operation.done) {90 await new Promise(resolve => setTimeout(resolve, 5000));91 operation = await ai.operations.get({ operation });92 }9394 const response = await ai.models.generateContent({95 model: "gemini-3.8-flash",96 contents: "Can you tell me about [insert question]",97 config: {98 tools: [99 {100 fileSearch: {101 fileSearchStoreNames: [fileSearchStore.name]102 }103 }104 ]105 }106 });107108 console.log(response.text);109 }110111 run();112113Check the API reference for [`uploadToFileSearchStore`](https://ai.google.dev/api/file-search/file-search-stores#method:-media.uploadtofilesearchstore) for more information.114115## Importing files116117Alternatively, 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):118119### Python120121 from google import genai122 from google.genai import types123 import time124125 client = genai.Client()126127 # File name will be visible in citations128 sample_file = client.files.upload(file='sample.txt', config={'name': 'display_file_name'})129130 file_search_store = client.file_search_stores.create(131 config={132 'display_name': 'your-fileSearchStore-name',133 'embedding_model': 'models/gemini-embedding-2'134 }135 )136137 operation = client.file_search_stores.import_file(138 file_search_store_name=file_search_store.name,139 file_name=sample_file.name140 )141142 while not operation.done:143 time.sleep(5)144 operation = client.operations.get(operation)145146 response = client.models.generate_content(147 model="gemini-3.8-flash",148 contents="""Can you tell me about [insert question]""",149 config=types.GenerateContentConfig(150 tools=[151 types.Tool(152 file_search=types.FileSearch(153 file_search_store_names=[file_search_store.name]154 )155 )156 ]157 )158 )159160 print(response.text)161162### JavaScript163164 const { GoogleGenAI } = require('@google/genai');165166 const ai = new GoogleGenAI({});167168 async function run() {169 // File name will be visible in citations170 const sampleFile = await ai.files.upload({171 file: 'sample.txt',172 config: { name: 'file-name' }173 });174175 const fileSearchStore = await ai.fileSearchStores.create({176 config: {177 displayName: 'your-fileSearchStore-name',178 embeddingModel: 'models/gemini-embedding-2'179 }180 });181182 let operation = await ai.fileSearchStores.importFile({183 fileSearchStoreName: fileSearchStore.name,184 fileName: sampleFile.name185 });186187 while (!operation.done) {188 await new Promise(resolve => setTimeout(resolve, 5000));189 operation = await ai.operations.get({ operation: operation });190 }191192 const response = await ai.models.generateContent({193 model: "gemini-3.8-flash",194 contents: "Can you tell me about [insert question]",195 config: {196 tools: [197 {198 fileSearch: {199 fileSearchStoreNames: [fileSearchStore.name]200 }201 }202 ]203 }204 });205206 console.log(response.text);207 }208209 run();210211Check the API reference for [`importFile`](https://ai.google.dev/api/file-search/file-search-stores#method:-filesearchstores.importfile) for more information.212213## Chunking configuration214215When you import a file into a File Search store, it's automatically broken down216into chunks, embedded, indexed, and uploaded to your File Search store. If you217need more control over the chunking strategy, you can specify a218[`chunking_config`](https://ai.google.dev/api/file-search/file-search-stores#request-body_5) setting219to set a maximum number of tokens per chunk and maximum number of overlapping220tokens.221222### Python223224 from google import genai225 from google.genai import types226 import time227228 client = genai.Client()229230 operation = client.file_search_stores.upload_to_file_search_store(231 file_search_store_name=file_search_store.name,232 file_name=sample_file.name,233 config={234 'chunking_config': {235 'white_space_config': {236 'max_tokens_per_chunk': 200,237 'max_overlap_tokens': 20238 }239 }240 }241 )242243 while not operation.done:244 time.sleep(5)245 operation = client.operations.get(operation)246247 print("Custom chunking complete.")248249### JavaScript250251 const { GoogleGenAI } = require('@google/genai');252253 const ai = new GoogleGenAI({});254255 let operation = await ai.fileSearchStores.uploadToFileSearchStore({256 file: 'file.txt',257 fileSearchStoreName: fileSearchStore.name,258 config: {259 displayName: 'file-name',260 chunkingConfig: {261 whiteSpaceConfig: {262 maxTokensPerChunk: 200,263 maxOverlapTokens: 20264 }265 }266 }267 });268269 while (!operation.done) {270 await new Promise(resolve => setTimeout(resolve, 5000));271 operation = await ai.operations.get({ operation });272 }273 console.log("Custom chunking complete.");274275To use your File Search store, pass it as a tool to the `generateContent`276method, as shown in the [Upload](https://ai.google.dev/gemini-api/docs/generate-content/file-search#upload) and [Import](https://ai.google.dev/gemini-api/docs/generate-content/file-search#importing-files) examples.277278## How it works279280File Search uses a technique called semantic search to find information relevant281to the user prompt. Unlike standard keyword-based search, semantic search282understands the meaning and context of your query.283284When you import a file, it's converted into numerical representations called285[embeddings](https://ai.google.dev/gemini-api/docs/embeddings), which capture the semantic meaning of286the uploaded content. These embeddings are stored in a specialized File Search database.287When you make a query, it's also converted into an embedding. Then the system288performs a File Search to find the most similar and relevant document chunks289from the File Search store.290291There is no Time To Live (TTL) for embeddings;292they persist until manually deleted, or when the model is deprecated. Files,293however, are deleted after 48 hours.294295Here's a breakdown of the process for using the File Search296`uploadToFileSearchStore` API:2972981. **Create a File Search store**: A File Search store contains the processed299 data from your files. It's the persistent container for the embeddings that the300 semantic search will operate on.3013022. **Upload a file and import into a File Search store** : Simultaneously upload303 a file and import the results into your File Search store. This creates a304 temporary `File` object, which is a reference to your raw document. That data is305 then chunked, converted into File Search embeddings, and indexed. The `File`306 object gets deleted after 48 hours, while the data imported into the File Search307 store will be stored indefinitely until you choose to delete it.3083093. **Query with File Search** : Finally, you use the `FileSearch` tool in a310 `generateContent` call. In the tool configuration, you specify a311 `FileSearchRetrievalResource`, which points to the `FileSearchStore` you want to312 search. This tells the model to perform a semantic search on that specific313 File Search store to find relevant information to ground its response.314315 The indexing and querying process of File Search316317In this diagram, the dotted line from *Documents* to *Embedding model*318(using [`gemini-embedding-001`](https://ai.google.dev/gemini-api/docs/embeddings))319represents the `uploadToFileSearchStore` API (bypassing *File storage* ).320Otherwise, using the [Files API](https://ai.google.dev/gemini-api/docs/files) to separately create321and then import files moves the indexing process from *Documents* to322*File storage* and then to *Embedding model*.323324## File Search stores325326A File Search store is a container for your document embeddings. While raw files327uploaded through the File API are deleted after 48 hours, the data imported into328a File Search store is stored indefinitely until you manually delete it. You can329create multiple File Search stores to organize your documents. The330`FileSearchStore` API lets you create, list, get, and delete to manage your file331search stores. File Search store names are globally scoped.332333Here are some examples of how to manage your File Search stores:334335### Python336337 file_search_store = client.file_search_stores.create(338 config={339 'display_name': 'my-file_search-store-123',340 'embedding_model': 'models/gemini-embedding-2'341 }342 )343344 for file_search_store in client.file_search_stores.list():345 print(file_search_store)346347 my_file_search_store = client.file_search_stores.get(name='fileSearchStores/my-file_search-store-123')348349 client.file_search_stores.delete(name='fileSearchStores/my-file_search-store-123', config={'force': True})350351### JavaScript352353 const fileSearchStore = await ai.fileSearchStores.create({354 config: {355 displayName: 'my-file_search-store-123',356 embeddingModel: 'models/gemini-embedding-2'357 }358 });359360 const fileSearchStores = await ai.fileSearchStores.list();361 for await (const store of fileSearchStores) {362 console.log(store);363 }364365 const myFileSearchStore = await ai.fileSearchStores.get({366 name: 'fileSearchStores/my-file_search-store-123'367 });368369 await ai.fileSearchStores.delete({370 name: 'fileSearchStores/my-file_search-store-123',371 config: { force: true }372 });373374### REST375376 curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \377 -H "Content-Type: application/json" \378 -d '{ "displayName": "My Store", "embedding_model": "models/gemini-embedding-2" }'379380 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=${GEMINI_API_KEY}" \381382 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123?key=${GEMINI_API_KEY}"383384 curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123?key=${GEMINI_API_KEY}"385386## File Search documents387388You can manage individual documents in your file stores with the389[File Search Documents](https://ai.google.dev/api/file-search/documents) API to `list` each document390in a file search store, `get` information about a document, and `delete` a391document by name.392393### Python394395 for document_in_store in client.file_search_stores.documents.list(parent='fileSearchStores/my-file_search-store-123'):396 print(document_in_store)397398 file_search_document = client.file_search_stores.documents.get(name='fileSearchStores/my-file_search-store-123/documents/my_doc')399 print(file_search_document)400401 client.file_search_stores.documents.delete(name='fileSearchStores/my-file_search-store-123/documents/my_doc')402403### JavaScript404405 const documents = await ai.fileSearchStores.documents.list({406 parent: 'fileSearchStores/my-file_search-store-123'407 });408 for await (const doc of documents) {409 console.log(doc);410 }411412 const fileSearchDocument = await ai.fileSearchStores.documents.get({413 name: 'fileSearchStores/my-file_search-store-123/documents/my_doc',414 });415416 await ai.fileSearchStores.documents.delete({417 name: 'fileSearchStores/my-file_search-store-123/documents/my_doc'418 });419420### REST421422 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123/documents?key=${GEMINI_API_KEY}"423424 curl "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123/documents/my_doc?key=${GEMINI_API_KEY}"425426 curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/fileSearchStores/my-file_search-store-123/documents/my_doc?key=${GEMINI_API_KEY}"427428## File metadata429430You can add custom metadata to your files to help filter them or provide431additional context. Metadata is a set of key-value pairs.432433### Python434435 op = client.file_search_stores.import_file(436 file_search_store_name=file_search_store.name,437 file_name=sample_file.name,438 custom_metadata=[439 {"key": "author", "string_value": "Robert Graves"},440 {"key": "year", "numeric_value": 1934}441 ]442 )443444### JavaScript445446 let operation = await ai.fileSearchStores.importFile({447 fileSearchStoreName: fileSearchStore.name,448 fileName: sampleFile.name,449 config: {450 customMetadata: [451 { key: "author", stringValue: "Robert Graves" },452 { key: "year", numericValue: 1934 }453 ]454 }455 });456457This is useful when you have multiple documents in a File Search store and want458to search only a subset of them.459460### Python461462 response = client.models.generate_content(463 model="gemini-3.8-flash",464 contents="Tell me about the book 'I, Claudius'",465 config=types.GenerateContentConfig(466 tools=[467 types.Tool(468 file_search=types.FileSearch(469 file_search_store_names=[file_search_store.name],470 metadata_filter="author=Robert Graves",471 )472 )473 ]474 )475 )476477 print(response.text)478479### JavaScript480481 const response = await ai.models.generateContent({482 model: "gemini-3.8-flash",483 contents: "Tell me about the book 'I, Claudius'",484 config: {485 tools: [486 {487 fileSearch: {488 fileSearchStoreNames: [fileSearchStore.name],489 metadataFilter: 'author="Robert Graves"',490 }491 }492 ]493 }494 });495496 console.log(response.text);497498### REST499500 curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=${GEMINI_API_KEY}" \501 -H 'Content-Type: application/json' \502 -X POST \503 -d '{504 "contents": [{505 "parts":[{"text": "Tell me about the book I, Claudius"}]506 }],507 "tools": [{508 "file_search": {509 "file_search_store_names":["'$STORE_NAME'"],510 "metadata_filter": "author = \"Robert Graves\""511 }512 }]513 }' 2> /dev/null > response.json514515 cat response.json516517Guidance on implementing list filter syntax for `metadata_filter` can be found518at [google.aip.dev/160](https://google.aip.dev/160)519520## Multimodal File Search521522Multimodal File Search lets you to natively embed and search through images,523enabling rich, multimodal RAG applications.524525### Configure the embedding model526527When you create a `FileSearchStore`, you must override the default text-only528embedding model to use a multimodal model. Use `models/gemini-embedding-2` to529process both text and images.530531### Python532533 store = client.file_search_stores.create(534 config={535 "display_name": "Multimodal Catalog",536 "embedding_model": "models/gemini-embedding-2",537 }538 )539540### JavaScript541542 const fileSearchStore = await ai.fileSearchStores.create({543 config: {544 displayName: "Multimodal Catalog",545 embeddingModel: "models/gemini-embedding-2",546 },547 });548549### REST550551 curl -X POST "https://generativelanguage.googleapis.com/v1beta/fileSearchStores?key=$GEMINI_API_KEY" \552 -H "Content-Type: application/json" \553 -d '{554 "display_name": "Multimodal Catalog",555 "embedding_model": "models/gemini-embedding-2"556 }'557558### Upload images559560After you create the store with a multimodal embedding model, you can upload561image files directly using the same upload APIs described in562[Directly upload to File Search store](https://ai.google.dev/gemini-api/docs/generate-content/file-search#upload) or [Importing files](https://ai.google.dev/gemini-api/docs/generate-content/file-search#importing-files).563564**Image file requirements:**565566- Image files must be at most 4K x 4K pixels in resolution.567- Supported formats are PNG, JPEG.568569## Citations570571When you use File Search, the model's response may include citations that572specify which parts of your uploaded documents were used to generate the573answer. This helps with fact-checking and verification.574575You can access citation information through the `grounding_metadata` attribute576of the response.577578### Python579580 print(response.candidates[0].grounding_metadata)581582### JavaScript583584 console.log(JSON.stringify(response.candidates?.[0]?.groundingMetadata, null, 2));585586For detailed information on the structure of the grounding metadata, see the587examples in the [File Search588cookbook](https://github.com/google-gemini/cookbook/blob/main/quickstarts/File_Search.ipynb)589or [the grounding section of the Grounding with Google590Search](https://ai.google.dev/gemini-api/docs/google-search#attributing_sources_with_inline_citations)591docs.592593### Page numbers594595When you use File Search with documents that have pages (such as PDFs), the596model's response may include the page number where the information was found.597You can access this information through the `page_number` attribute of the598`retrieved_context`.599600### Python601602 # Iterate through citations and check for page numbers603 for chunk in response.grounding_metadata.grounding_chunks:604 if chunk.retrieved_context and chunk.retrieved_context.page_number:605 print(f"Cited Page: {chunk.retrieved_context.page_number}")606607### JavaScript608609 const groundingMetadata = response.candidates[0].groundingMetadata;610 for (const chunk of groundingMetadata.groundingChunks) {611 if (chunk.retrievedContext && chunk.retrievedContext.pageNumber) {612 console.log(`Cited Page: ${chunk.retrievedContext.pageNumber}`);613 }614 }615616### Media citations617618When the model references an image chunk during generation, the API returns a619citation in the grounding metadata that includes a `media_id`. You can use this620ID to download the exact image chunk the model referenced. This `media_id` is621persistent across multiple search calls, which lets you reliably retrieve622the same image or cache it using the ID.623624The following snippet is an example REST response:625626 "groundingMetadata": {627 "groundingChunks": [628 {629 "retrievedContext": {630 "title": "product_image",631 "fileSearchStore": "fileSearchStores/my-store-123",632 "media_id": "fileSearchStores/my-store-123/media/BlobId-456"633 }634 }635 ]636 }637638The following code snippets demonstrate how to retrieve the `media_id` and639download the media:640641### Python642643 # Iterate through citations and download media if present644 for chunk in response.grounding_metadata.grounding_chunks:645 if chunk.retrieved_context and chunk.retrieved_context.media_id:646 print(f"Cited Media ID: {chunk.retrieved_context.media_id}")647 # Download the blob using the SDK648 blob_content = client.file_search_stores.download_media(649 media_id=chunk.retrieved_context.media_id650 )651 # Save blob_content to file...652653### JavaScript654655 const groundingMetadata = response.candidates[0].groundingMetadata;656 for (const chunk of groundingMetadata.groundingChunks) {657 if (chunk.retrievedContext && chunk.retrievedContext.mediaId) {658 console.log(`Cited Media ID: ${chunk.retrievedContext.mediaId}`);659 const blobContent = await ai.fileSearchStores.downloadMedia(chunk.retrievedContext.mediaId);660 // Save blobContent to file...661 }662 }663664### REST665666 curl -X GET "https://generativelanguage.googleapis.com/v1/fileSearchStores/my-store-123/media/BlobId-456" \667 -H "x-goog-api-key: $GEMINI_API_KEY"668669## Custom metadata in grounding data670671If you have added custom metadata to your files, you can access it in the672grounding metadata of the model's response. This is useful for passing673additional context (like URLs, page numbers, or authors) from your source674documents to your application logic. Each `grounding_chunk` in the675`retrieved_context` contains this custom metadata.676677### Python678679 response = client.models.generate_content(680 model="gemini-3.8-flash",681 contents="Tell me about [insert question]",682 config=types.GenerateContentConfig(683 tools=[684 types.Tool(685 file_search=types.FileSearch(686 file_search_store_names=[file_search_store.name]687 )688 )689 ]690 )691 )692693 for chunk in response.candidates[0].grounding_metadata.grounding_chunks:694 if chunk.retrieved_context:695 print(f"Text: {chunk.retrieved_context.text}")696 if chunk.retrieved_context.custom_metadata:697 for metadata in chunk.retrieved_context.custom_metadata:698 print(f"Metadata Key: {metadata.key}")699 print(f"Value: {metadata.string_value or metadata.numeric_value}")700701### JavaScript702703 const response = await ai.models.generateContent({704 model: "gemini-3.8-flash",705 contents: "Tell me about [insert question]",706 config: {707 tools: [708 {709 fileSearch: {710 fileSearchStoreNames: [fileSearchStore.name]711 }712 }713 ]714 }715 });716717 const groundingMetadata = response.candidates[0].groundingMetadata;718 groundingMetadata.groundingChunks.forEach((chunk) => {719 if (chunk.retrievedContext) {720 console.log(`Text: ${chunk.retrievedContext.text}`);721 if (chunk.retrievedContext.customMetadata) {722 chunk.retrievedContext.customMetadata.forEach((metadata) => {723 console.log(`Metadata Key: ${metadata.key}`);724 console.log(`Value: ${metadata.stringValue || metadata.numericValue}`);725 });726 }727 }728 });729730### REST731732 {733 "candidates": [734 {735 "content": { ... },736 "grounding_metadata": {737 "grounding_chunks": [738 {739 "retrieved_context": {740 "text": "...",741 "title": "...",742 "uri": "...",743 "custom_metadata": [744 {745 "key": "author",746 "string_value": "Robert Graves"747 },748 {749 "key": "year",750 "numeric_value": 1934751 }752 ]753 }754 }755 ],756 "grounding_supports": [ ... ]757 }758 }759 ]760 }761762## Structured output763764Starting with Gemini 3 models, you can combine file search tool with765[structured outputs](https://ai.google.dev/gemini-api/docs/structured-output).766767### Python768769 from pydantic import BaseModel, Field770771 class Money(BaseModel):772 amount: str = Field(description="The numerical part of the amount.")773 currency: str = Field(description="The currency of amount.")774775 response = client.models.generate_content(776 model="gemini-3.8-flash",777 contents="What is the minimum hourly wage in Tokyo right now?",778 config=types.GenerateContentConfig(779 tools=[780 types.Tool(781 file_search=types.FileSearch(782 file_search_store_names=[file_search_store.name]783 )784 )785 ],786 response_format={"text": {"mime_type": "application/json", "schema": Money.model_json_schema()}}787 )788 )789 result = Money.model_validate_json(response.text)790 print(result)791792### JavaScript793794 import { z } from "zod";795796 const moneySchema = z.object({797 amount: z.string().describe("The numerical part of the amount."),798 currency: z.string().describe("The currency of amount."),799 });800801 async function run() {802 const response = await ai.models.generateContent({803 model: "gemini-3.8-flash",804 contents: "What is the minimum hourly wage in Tokyo right now?",805 config: {806 tools: [807 {808 fileSearch: {809 fileSearchStoreNames: [file_search_store.name],810 },811 },812 ],813 responseFormat: { text: { mimeType: "application/json", schema: z.toJSONSchema(moneySchema) } },814 },815 });816817 const result = moneySchema.parse(JSON.parse(response.text));818 console.log(result);819 }820821 run();822823### REST824825 curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent" \826 -H "x-goog-api-key: $GEMINI_API_KEY" \827 -H 'Content-Type: application/json' \828 -X POST \829 -d '{830 "contents": [{831 "parts": [{"text": "What is the minimum hourly wage in Tokyo right now?"}]832 }],833 "tools": [834 {835 "fileSearch": {836 "fileSearchStoreNames": ["$FILE_SEARCH_STORE_NAME"]837 }838 }839 ],840 "generationConfig": {841 "responseFormat": {842 "text": {843 "mimeType": "application/json",844 "schema": {845 "type": "object",846 "properties": {847 "amount": {"type": "string", "description": "The numerical part of the amount."},848 "currency": {"type": "string", "description": "The currency of amount."}849 }850 }851 },852 "required": ["amount", "currency"]853 }854 }855 }'856857## Supported models858859The following models support File Search:860861| Model | File Search |862|---|---|863| [Gemini 3.8 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.8-flash) | ✔️ |864| [Gemini 3.7 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.7-flash) | ✔️ |865| [Gemini 3.6 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.6-flash) | ✔️ |866| [Gemini 3.5 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash-lite) | ✔️ |867| [Gemini 3.5 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash) | ✔️ |868| [Gemini 3.1 Pro Preview](https://ai.google.dev/gemini-api/docs/gemini-3.1-pro-preview) | ✔️ |869| [Gemini 3.1 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-lite) | ✔️ |870| [Gemini 3 Flash Preview](https://ai.google.dev/gemini-api/docs/models/gemini-3-flash-preview) | ✔️ |871| [Gemini 2.5 Pro](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-pro) | ✔️ |872| [Gemini 2.5 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-lite) | ✔️ |873874## Supported tool combinations875876Gemini 3 models support combining built-in tools (like File Search) with custom877tools (function calling). Learn more on the878[tool combinations](https://ai.google.dev/gemini-api/docs/tool-combination) page.879880## Supported file types881882File Search supports a wide range of file formats, listed in the following883sections.884885### Application file types886887- `application/dart`888- `application/ecmascript`889- `application/json`890- `application/ms-java`891- `application/msword`892- `application/pdf`893- `application/sql`894- `application/typescript`895- `application/vnd.curl`896- `application/vnd.dart`897- `application/vnd.ibm.secure-container`898- `application/vnd.jupyter`899- `application/vnd.ms-excel`900- `application/vnd.oasis.opendocument.text`901- `application/vnd.openxmlformats-officedocument.presentationml.presentation`902- `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`903- `application/vnd.openxmlformats-officedocument.wordprocessingml.document`904- `application/vnd.openxmlformats-officedocument.wordprocessingml.template`905- `application/x-csh`906- `application/x-hwp`907- `application/x-hwp-v5`908- `application/x-latex`909- `application/x-php`910- `application/x-powershell`911- `application/x-sh`912- `application/x-shellscript`913- `application/x-tex`914- `application/x-zsh`915- `application/xml`916- `application/zip`917918### Text file types919920- `text/1d-interleaved-parityfec`921- `text/RED`922- `text/SGML`923- `text/cache-manifest`924- `text/calendar`925- `text/cql`926- `text/cql-extension`927- `text/cql-identifier`928- `text/css`929- `text/csv`930- `text/csv-schema`931- `text/dns`932- `text/encaprtp`933- `text/enriched`934- `text/example`935- `text/fhirpath`936- `text/flexfec`937- `text/fwdred`938- `text/gff3`939- `text/grammar-ref-list`940- `text/hl7v2`941- `text/html`942- `text/javascript`943- `text/jcr-cnd`944- `text/jsx`945- `text/markdown`946- `text/mizar`947- `text/n3`948- `text/parameters`949- `text/parityfec`950- `text/php`951- `text/plain`952- `text/provenance-notation`953- `text/prs.fallenstein.rst`954- `text/prs.lines.tag`955- `text/prs.prop.logic`956- `text/raptorfec`957- `text/rfc822-headers`958- `text/rtf`959- `text/rtp-enc-aescm128`960- `text/rtploopback`961- `text/rtx`962- `text/sgml`963- `text/shaclc`964- `text/shex`965- `text/spdx`966- `text/strings`967- `text/t140`968- `text/tab-separated-values`969- `text/texmacs`970- `text/troff`971- `text/tsv`972- `text/tsx`973- `text/turtle`974- `text/ulpfec`975- `text/uri-list`976- `text/vcard`977- `text/vnd.DMClientScript`978- `text/vnd.IPTC.NITF`979- `text/vnd.IPTC.NewsML`980- `text/vnd.a`981- `text/vnd.abc`982- `text/vnd.ascii-art`983- `text/vnd.curl`984- `text/vnd.debian.copyright`985- `text/vnd.dvb.subtitle`986- `text/vnd.esmertec.theme-descriptor`987- `text/vnd.exchangeable`988- `text/vnd.familysearch.gedcom`989- `text/vnd.ficlab.flt`990- `text/vnd.fly`991- `text/vnd.fmi.flexstor`992- `text/vnd.gml`993- `text/vnd.graphviz`994- `text/vnd.hans`995- `text/vnd.hgl`996- `text/vnd.in3d.3dml`997- `text/vnd.in3d.spot`998- `text/vnd.latex-z`999- `text/vnd.motorola.reflex`1000- `text/vnd.ms-mediapackage`1001- `text/vnd.net2phone.commcenter.command`1002- `text/vnd.radisys.msml-basic-layout`1003- `text/vnd.senx.warpscript`1004- `text/vnd.sosi`1005- `text/vnd.sun.j2me.app-descriptor`1006- `text/vnd.trolltech.linguist`1007- `text/vnd.wap.si`1008- `text/vnd.wap.sl`1009- `text/vnd.wap.wml`1010- `text/vnd.wap.wmlscript`1011- `text/vtt`1012- `text/wgsl`1013- `text/x-asm`1014- `text/x-bibtex`1015- `text/x-boo`1016- `text/x-c`1017- `text/x-c++hdr`1018- `text/x-c++src`1019- `text/x-cassandra`1020- `text/x-chdr`1021- `text/x-coffeescript`1022- `text/x-component`1023- `text/x-csh`1024- `text/x-csharp`1025- `text/x-csrc`1026- `text/x-cuda`1027- `text/x-d`1028- `text/x-diff`1029- `text/x-dsrc`1030- `text/x-emacs-lisp`1031- `text/x-erlang`1032- `text/x-gff3`1033- `text/x-go`1034- `text/x-haskell`1035- `text/x-java`1036- `text/x-java-properties`1037- `text/x-java-source`1038- `text/x-kotlin`1039- `text/x-lilypond`1040- `text/x-lisp`1041- `text/x-literate-haskell`1042- `text/x-lua`1043- `text/x-moc`1044- `text/x-objcsrc`1045- `text/x-pascal`1046- `text/x-pcs-gcd`1047- `text/x-perl`1048- `text/x-perl-script`1049- `text/x-python`1050- `text/x-python-script`1051- `text/x-r-markdown`1052- `text/x-rsrc`1053- `text/x-rst`1054- `text/x-ruby-script`1055- `text/x-rust`1056- `text/x-sass`1057- `text/x-scala`1058- `text/x-scheme`1059- `text/x-script.python`1060- `text/x-scss`1061- `text/x-setext`1062- `text/x-sfv`1063- `text/x-sh`1064- `text/x-siesta`1065- `text/x-sos`1066- `text/x-sql`1067- `text/x-swift`1068- `text/x-tcl`1069- `text/x-tex`1070- `text/x-vbasic`1071- `text/x-vcalendar`1072- `text/xml`1073- `text/xml-dtd`1074- `text/xml-external-parsed-entity`1075- `text/yaml`10761077## Limitations10781079- **Live API:** File Search is not supported in the [Live API](https://ai.google.dev/gemini-api/docs/live).1080- **Tool incompatibility:** File Search cannot be combined with other tools like [Grounding with Google Search](https://ai.google.dev/gemini-api/docs/google-search), [URL Context](https://ai.google.dev/gemini-api/docs/url-context), etc. at this time.10811082### Rate limits10831084The File Search API has the following limits to enforce service stability:10851086- **Maximum file size / per document limit**: 100 MB1087- **Total size of project File Search stores** (based on user tier):1088 - **Free**: 1 GB1089 - **Tier 1**: 10 GB1090 - **Tier 2**: 100 GB1091 - **Tier 3**: 1 TB1092- **Recommendation**: Limit the size of each File Search store to under 20 GB to ensure optimal retrieval latencies.10931094> [!NOTE]1095> **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.10961097## Pricing10981099- You are charged for embeddings at indexing time based on existing [embeddings pricing](https://ai.google.dev/gemini-api/docs/pricing#gemini-embedding-2).1100- Storage is free of charge.1101- Query time embeddings are free of charge.1102- Retrieved document tokens are charged as regular [context tokens](https://ai.google.dev/gemini-api/docs/tokens).11031104## What's next11051106- 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).