Scripts Gemini model responses so workflows run without real API calls.
Pass canned response bodies built with text_response /
function_call_response. Each model call — including each turn of an
automatic-function-calling loop and each generate_content_stream call —
consumes the next response in order. Build a plugin with plugin
and register it on your worker; inspect requests afterwards to
assert exactly what the integration sent.
Only model calls (client.models) are scripted. File, interaction, and agent operations are not; mock those on a genai.Client directly if a test needs them.
| Method | __init__ |
Initialize with the response bodies to serve, in order. |
| Method | plugin |
Return a GoogleGenAIPlugin whose model calls serve the script. |
| Instance Variable | requests |
Undocumented |
| Method | _next |
Undocumented |
| Instance Variable | _index |
Undocumented |
| Instance Variable | _responses |
Undocumented |
Return a GoogleGenAIPlugin whose model calls serve the script.
The real plugin activities run; only the underlying HTTP layer is replaced, so request formatting and the AFC loop are exercised exactly as in production.