Google File Search API patterns for managed RAG with Gemini. Covers both TypeScript (@google/genai) and Python (google-genai) SDKs. Use when building File Search integrations, implementing RAG with Google AI, or when user mentions Google File Search, Gemini RAG, document indexing, or semantic search.
View on GitHubvanman2024/ai-dev-marketplace
rag-pipeline
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/ai-dev-marketplace/blob/main/plugins/rag-pipeline/skills/google-file-search/SKILL.md -a claude-code --skill google-file-searchInstallation paths:
.claude/skills/google-file-search/# Google File Search
Comprehensive skill for implementing Google File Search API with Gemini models for Retrieval-Augmented Generation (RAG).
## Overview
Google File Search provides managed RAG capabilities through:
- Automatic document chunking and embedding generation
- Semantic search across multiple document types
- Metadata-based filtering for targeted retrieval
- Grounding citations showing source documents
- Persistent storage with file search stores
- Integration with Gemini 2.5 models
**Two Official SDKs are available:**
- **TypeScript/JavaScript:** `@google/genai` npm package
- **Python:** `google-genai` pip package
## CRITICAL: Use Official SDKs Only
Do NOT use manual REST API calls or deprecated packages. Always use the official SDKs.
### TypeScript/JavaScript
```bash
npm install @google/genai
```
### Python
```bash
pip install google-genai
```
## Security: API Key Handling
**CRITICAL:** Never hardcode API keys.
```typescript
// ✅ CORRECT - TypeScript
const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY! });
// ❌ WRONG
const ai = new GoogleGenAI({ apiKey: 'sk-abc123...' });
```
```python
# ✅ CORRECT - Python
client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
# ❌ WRONG
client = genai.Client(api_key="sk-abc123...")
```
Get API keys from: https://aistudio.google.com/apikey
## TypeScript Implementation
### Initialize Client
```typescript
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY! });
```
### Create File Search Store
```typescript
const store = await ai.fileSearchStores.create({
config: { displayName: 'my-knowledge-base' }
});
console.log(`Store created: ${store.name}`);
```
### Upload and Index Documents
**Use `uploadToFileSearchStore()` which uploads AND indexes in one operation.**
```typescript
async function uploadFile(storeName: string, filePath: string, filename: string) {
let operation = await ai.fileSearchStores.uploadToFileSearchStore({