google.generativeai.GenerativeModel.generate_content and its async counterpart.
Requirements
| Requirement | Version |
|---|---|
google-generativeai SDK | any recent release |
| Python | ≥ 3.9 |
What gets patched
Non-streaming
Streaming
For streaming, actguard readsusage_metadata from the first chunk that carries it:
Async client
Model name normalisation
The Google SDK prefixes model names withmodels/ (e.g. models/gemini-1.5-pro). actguard strips this prefix before looking up the pricing table, so gemini-1.5-pro is the key used for cost calculation.