Google Gemini¶
Simulate Gemini generate content in your tests.
Compatibility
See Compatibility for providers, transports, and framework recipes.
How it works¶
Tenro intercepts the Gemini SDK's outbound HTTP request and returns your configured response. No real network call is made.
from google import genai
client = genai.Client(api_key="your-key")
response = client.models.generate_content(
model="gemini-2.0-flash",
contents="Hello",
)
# In tests, Tenro returns your simulated response
Capabilities¶
| Capability | Supported | Notes |
|---|---|---|
| TEXT | Yes | Basic text generation |
| FUNCTION_CALL | Yes | Gemini-style function calling |
| STREAMING | Coming soon | Server-sent events |
Simulating responses¶
Basic text¶
from tenro import Provider
from tenro.simulate import llm, tool
llm.simulate(Provider.GEMINI, response="Hello!")
With function calls¶
Use ToolCall to simulate LLM responses that include function calls:
from tenro import Provider, ToolCall
from tenro.simulate import llm
# Single response with text + tool call (nested list = one LLM call)
llm.simulate(
provider=Provider.GEMINI,
responses=[["I'll search for that.", ToolCall(search, query="AI")]]
)
# Tool call only (no text)
llm.simulate(
provider=Provider.GEMINI,
responses=[ToolCall("search", query="AI")]
)
Provider format handled automatically
ToolCall uses a unified format. Tenro converts to Gemini's native format (with args instead of arguments) internally.
Multi-turn conversations¶
from tenro import Provider
from tenro.simulate import llm, tool
llm.simulate(
provider=Provider.GEMINI,
responses=[
"Let me think about that...", # First LLM call
"Here's my answer: 42" # Second LLM call
]
)
Response format¶
Tenro returns a valid Gemini GenerateContentResponse object:
{
"candidates": [{
"content": {
"parts": [{"text": "Hello!"}],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 5,
"totalTokenCount": 15
}
}
See also¶
- LLM Providers - All supported providers
- OpenAI - Compare with OpenAI's format