Document → Import
AI-generatedSummary
Import a file into a Gemini File Search store, optionally setting display name, custom metadata, chunking, and completion behavior.
Inputs
- storeName (required) — The File Search store to operate on
- displayName — Human‑readable display name for the document
- customMetadata — Custom metadata key‑value pairs (max 20)
- chunkingOptions — Chunking options such as max tokens per chunk and overlap
- waitForCompletion — Whether to wait for the upload/import operation to complete
- fileName (required) — The resource name of the file to import (from Files API)
Output shape
a single document object
Successful calls return the imported document details; errors are returned as JSON error objects.
Examples
Example 1: Import a PDF with a custom display name and metadata
storeName: 'fileSearchStores/my-store-123', fileName: 'files/report.pdf', displayName: 'Q1 Report', customMetadata: [{key:'department',valueType:'string',value:'Finance'}], chunkingOptions: {maxTokensPerChunk:200, maxOverlapTokens:20}, waitForCompletion:true
Example 2: Replace an existing document without waiting for completion
operation: 'replaceUpload', storeName: 'fileSearchStores/abc', fileName: 'files/old.docx', waitForCompletion:false
Example 3: Import a CSV and add custom metadata, skipping wait
storeName: 'fileSearchStores/xyz', fileName: 'files/data.csv', waitForCompletion:false, customMetadata: [{key:'source',valueType:'string',value:'external'}], chunkingOptions: {maxTokensPerChunk:150}