BerriAI/litellm · error · ValueError
GEMINI_API_KEY or GOOGLE_API_KEY is required for Gemini File
Error message
GEMINI_API_KEY or GOOGLE_API_KEY is required for Gemini File Search
What it means
Credential guard in the Gemini File Search ingestion flow: neither vector_store_config['api_key'] nor the GEMINI_API_KEY/GOOGLE_API_KEY environment variables yielded an API key, so requests to the Gemini File API cannot be authenticated. Set one of those environment variables or pass api_key in the vector store credentials.
Source
Thrown at litellm/rag/ingestion/gemini_ingestion.py:93
filename: Name of the file
content_type: MIME type
chunks: Ignored - Gemini handles chunking
embeddings: Ignored - Gemini handles embedding
existing_file_id: Existing provider file ID, unsupported for Gemini
Returns:
Tuple of (vector_store_id, file_id)
"""
vector_store_id = self.vector_store_config.get("vector_store_id")
vector_store_config: Final = cast(dict[str, Any], self.vector_store_config)
# Get API credentials
api_key: Final = cast(str | None, vector_store_config.get("api_key")) or GeminiModelInfo.get_api_key()
api_base: Final = cast(str | None, vector_store_config.get("api_base")) or GeminiModelInfo.get_api_base()
if not api_key:
raise ValueError("GEMINI_API_KEY or GOOGLE_API_KEY is required for Gemini File Search")
if not api_base:
raise ValueError("GEMINI_API_BASE is required")
api_version: Final = "v1beta"
base_url: Final = f"{api_base}/{api_version}"
# Create File Search store if not provided
if not vector_store_id:
vector_store_id = await self._create_file_search_store(
api_key=api_key,
base_url=base_url,
display_name=self.ingest_name or "litellm-rag-ingest",
)
# Upload file to File Search store
result_file_id = None
if file_content and filename and vector_store_id:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set GEMINI_API_KEY or GOOGLE_API_KEY in your environment.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/rag/ingestion/gemini_ingestion.py:93 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/2d08b7bddc320af6.
Report an issue: GitHub.