From e59d5aba4f904d2039f03718365280608d66fe5a Mon Sep 17 00:00:00 2001 From: Ryuichi Watanabe Date: Tue, 13 May 2025 23:53:54 +0900 Subject: [PATCH 1/2] Added the requirement for the GEMINI_API_KEY environment variable to the README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 3bf776ac8..eb79a8eb1 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,14 @@ Provides the ability to [stream](https://ai.pydantic.dev/output/#streamed-result Here's a minimal example of PydanticAI: ```python +import os from pydantic_ai import Agent +# Ensure the GEMINI_API_KEY environment variable is set before running the agent +gemini_api_key = os.getenv("GEMINI_API_KEY") +if gemini_api_key is None: + raise ValueError("Please set the GEMINI_API_KEY environment variable.") + # Define a very simple agent including the model to use, you can also set the model when running the agent. agent = Agent( 'google-gla:gemini-1.5-flash', From ca00f7ec4527aee6ce37199f6dccc76dafc57f57 Mon Sep 17 00:00:00 2001 From: Ryuichi Watanabe Date: Wed, 14 May 2025 09:54:02 +0900 Subject: [PATCH 2/2] Do not modify the code --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index eb79a8eb1..c691a4bd4 100644 --- a/README.md +++ b/README.md @@ -66,14 +66,8 @@ Provides the ability to [stream](https://ai.pydantic.dev/output/#streamed-result Here's a minimal example of PydanticAI: ```python -import os from pydantic_ai import Agent -# Ensure the GEMINI_API_KEY environment variable is set before running the agent -gemini_api_key = os.getenv("GEMINI_API_KEY") -if gemini_api_key is None: - raise ValueError("Please set the GEMINI_API_KEY environment variable.") - # Define a very simple agent including the model to use, you can also set the model when running the agent. agent = Agent( 'google-gla:gemini-1.5-flash', @@ -96,6 +90,8 @@ _(This example is complete, it can be run "as is")_ Not very interesting yet, but we can easily add "tools", dynamic system prompts, and structured responses to build more powerful agents. +Ensure the GEMINI_API_KEY environment variable is set before running the agent + ## Tools & Dependency Injection Example Here is a concise example using PydanticAI to build a support agent for a bank: