Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
id: dd53e420ef
question: What needs to change in `agent.py` to use Gemini instead of OpenAI?
sort_order: 32
---

To use Gemini with PydanticAI, update the provider prefix in your `Agent` setup from `openai:` to `google:`.

For example:

```python
faq_agent = Agent(
"google:gemini-3.1-flash-lite",
deps_type=SearchDeps,
instructions=INSTRUCTIONS,
)
```

Also update your API key environment variable to the Gemini one the code expects (typically `GOOGLE_API_KEY`).