[Feature Request]: Add Support for Cached Content in llama_index.llms.google_genai

### Feature Description

I am requesting the addition of support for the `cached_content` feature in the `llama_index.llms.google_genai` module to enable context caching with Google's Gemini API. This feature would allow users to store and reuse input tokens for repetitive requests, reducing latency and costs when processing large or frequently referenced contexts, such as PDF documents or extensive system prompts.

The proposed integration would align with the existing Google GenAI SDK's context caching functionality, as demonstrated in the following example:

```python
from google import genai
from google.genai.types import CreateCachedContentConfig, Content, Part, HttpOptions
from llama_index.core.llms import ChatMessage
from llama_index.llms.google_genai import GoogleGenAI

# Initialize Google GenAI client for Vertex AI
client = genai.Client(
    http_options=HttpOptions(api_version="v1"),
    project="...",
    location="us-central1",
    vertexai=True
)

# Define content for caching (e.g., PDF files)
contents = [
    Content(
        role="user",
        parts=[
            Part.from_uri(
                file_uri="gs://cloud-samples-data/generative-ai/pdf/2312.11805v3.pdf",
                mime_type="application/pdf",
            ),
            Part.from_uri(
                file_uri="gs://cloud-samples-data/generative-ai/pdf/2403.05530.pdf",
                mime_type="application/pdf",
            ),
        ],
    )
]

model = "gemini-2.0-flash-001"

# Create cache
cache = client.caches.create(
    model=model,
    config=CreateCachedContentConfig(
        display_name='OS Book',
        system_instruction=(
            'You are an expert PDF analyzer, and your job is to answer '
            'the user\'s query based on the PDF file you have access to.'
        ),
        contents=contents,
        ttl="300s",
    )
)

# Initialize GoogleGenAI with cached_content
llm = GoogleGenAI(
    model=model,
    vertexai_config={"project": "...", "location": "us-central1"},
    cached_content=cache.name,
)

# Query using cached content
message = ChatMessage(role="user", content="Summarize the key points.")
response = llm.chat([message])
print(response)
```

**References:**  
- Google Gemini API Context Caching: https://ai.google.dev/gemini-api/docs/caching  
- Google Cloud Vertex AI Context Caching https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview

### Reason

Currently, the `GoogleGenAI` class in LlamaIndex does not support the `cached_content` parameter, resulting in an inability to leverage this feature. Adding support would involve updating the `GoogleGenAI` class to accept a `cached_content` parameter and pass it to the underlying Google GenAI SDK when initializing the model, similar to how `vertexai_config` is handled.

### Value of Feature

This feature would enhance the efficiency of LlamaIndex applications using Google’s Gemini models, particularly for use cases involving large documents or repetitive queries, and align with the cost-saving benefits highlighted in Google’s documentation.

Labels: enhancement, triage
State: closed