googleapis / googleapis/python-genai
Add labels support for Vertex AI Context Caching cost tracking
- Lingua principale
- Python
- Stelle
- 4k
- Fork
- 1k
- Merge medio
- 2g 12h
- PR unite (30g)
- 41
Descrizione
Description
The CreateCachedContentConfig does not support labels for cost tracking and billing attribution. This makes it difficult to allocate context caching costs across teams, environments, and projects.
Current Behavior
Adding labels to cache creation fails with a validation error:
```
config = CreateCachedContentConfig(
system_instruction="...",
contents=["..."],
ttl="3600s",
display_name="my-cache",
labels={ # This causes an error
"environment": "production",
"team": "ai-team"
}
)
client = genai.Client(vertexai=True, project=project, location=selected_location)
cache = await client.aio.caches.create(model="gemini-2.5-flash-lite", config=config)
```
**Error:**
```
1 validation error for CreateCachedContentConfig
labels
Extra inputs are not permitted [type=extra_forbidden, input_value={'environment': 'production'}, input_type=dict]`
```
Expected Behavior
```
Labels should be supported for context caching, similar to other Vertex AI resources:
config = CreateCachedContentConfig(
system_instruction="...",
contents=["..."],
ttl="3600s",
display_name="my-cache",
labels={ # Should work
"environment": "production",
"team": "ai-team",
"cost-center": "engineering"
}
)
```
Use Case
We need to track cache creation costs per team/environment for accurate billing and chargeback. Context caching incurs significant costs that require proper attribution for multi-tenant systems.
Environment
SDK Version: 1.52.0
Python Version: 3.12
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.