You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Get Started with Microsoft Agent Framework Google
2
2
3
-
> **Note**: This package is currently under active development. The chat client implementation for Google AI is coming soon. This initial release provides the foundational settings and configuration classes.
4
-
5
3
Please install this package via pip:
6
4
7
5
```bash
@@ -16,27 +14,31 @@ This package provides integration with Google's Gemini API for Agent Framework:
16
14
17
15
> **Note**: This package uses the new `google-genai` SDK as recommended by Google. See the [migration guide](https://ai.google.dev/gemini-api/docs/migrate) for more information.
18
16
19
-
### Current Status
17
+
### Current Features
20
18
21
19
**Available Now:**
22
20
-`GoogleAISettings`: Configuration class for Google AI (Gemini API) authentication and settings
21
+
-`GoogleAIChatClient`: Chat client for Google AI with streaming, function calling, and multi-turn conversation support
22
+
- Function calling with `@AIFunction` decorator and plain Python functions
23
+
- Multi-modal support (images)
24
+
- Full `ChatOptions` support (temperature, top_p, max_tokens, stop sequences)
25
+
- Usage tracking and OpenTelemetry observability
23
26
24
27
**Coming Soon:**
25
-
-`GoogleAIChatClient`: Chat client for Google AI with streaming, function calling, and multi-modal support
26
-
- Integration tests and usage samples
28
+
- Advanced features (context caching, safety settings, structured output)
29
+
- Thinking mode (Gemini 2.5)
30
+
- Enhanced error handling with retry policies
27
31
28
32
### Configuration
29
33
30
-
You can configure the settings class now, which will be used by the chat client in the next release:
31
-
32
34
#### Google AI Settings
33
35
34
36
```python
35
37
from agent_framework_google import GoogleAISettings
36
38
37
39
# Configure via environment variables
38
40
# GOOGLE_AI_API_KEY=your_api_key
39
-
# GOOGLE_AI_CHAT_MODEL_ID=gemini-1.5-pro
41
+
# GOOGLE_AI_CHAT_MODEL_ID=gemini-2.5-flash
40
42
41
43
settings = GoogleAISettings()
42
44
@@ -45,73 +47,204 @@ from pydantic import SecretStr
45
47
46
48
settings = GoogleAISettings(
47
49
api_key=SecretStr("your_api_key"),
48
-
chat_model_id="gemini-1.5-pro"
50
+
chat_model_id="gemini-2.5-flash"
49
51
)
50
52
```
51
53
52
-
### Future Usage (Coming Soon)
54
+
### Usage Examples
55
+
56
+
#### Basic Chat Completion
57
+
58
+
```python
59
+
import asyncio
60
+
from agent_framework import ChatMessage, Role, ChatOptions
61
+
from agent_framework_google import GoogleAIChatClient
62
+
63
+
asyncdefmain():
64
+
# Configure via environment variables
65
+
# GOOGLE_AI_API_KEY=your_api_key
66
+
# GOOGLE_AI_CHAT_MODEL_ID=gemini-2.5-flash
67
+
68
+
client = GoogleAIChatClient()
69
+
70
+
# Create a simple chat message
71
+
messages = [
72
+
ChatMessage(role=Role.USER, text="What is the capital of France?")
73
+
]
74
+
75
+
# Get response
76
+
response =await client.get_response(
77
+
messages=messages,
78
+
chat_options=ChatOptions()
79
+
)
80
+
81
+
print(response.messages[0].text)
82
+
# Output: Paris is the capital of France.
83
+
84
+
# Run the async function
85
+
asyncio.run(main())
86
+
```
87
+
88
+
#### Streaming Chat
89
+
90
+
```python
91
+
import asyncio
92
+
from agent_framework import ChatMessage, Role, ChatOptions
93
+
from agent_framework_google import GoogleAIChatClient
94
+
95
+
asyncdefmain():
96
+
client = GoogleAIChatClient()
97
+
98
+
messages = [
99
+
ChatMessage(role=Role.USER, text="Write a short poem about programming.")
100
+
]
101
+
102
+
# Stream the response
103
+
asyncfor chunk in client.get_streaming_response(
104
+
messages=messages,
105
+
chat_options=ChatOptions()
106
+
):
107
+
if chunk.text:
108
+
print(chunk.text, end="", flush=True)
109
+
110
+
# Run the async function
111
+
asyncio.run(main())
112
+
```
113
+
114
+
#### Chat with System Instructions
115
+
116
+
```python
117
+
import asyncio
118
+
from agent_framework import ChatMessage, Role, ChatOptions
119
+
from agent_framework_google import GoogleAIChatClient
120
+
121
+
asyncdefmain():
122
+
client = GoogleAIChatClient()
123
+
124
+
messages = [
125
+
ChatMessage(role=Role.SYSTEM, text="You are a helpful coding assistant."),
126
+
ChatMessage(role=Role.USER, text="How do I reverse a string in Python?")
127
+
]
128
+
129
+
response =await client.get_response(
130
+
messages=messages,
131
+
chat_options=ChatOptions()
132
+
)
133
+
134
+
print(response.messages[0].text)
135
+
136
+
# Run the async function
137
+
asyncio.run(main())
138
+
```
139
+
140
+
#### Multi-Turn Conversation
141
+
142
+
```python
143
+
import asyncio
144
+
from agent_framework import ChatMessage, Role, ChatOptions
145
+
from agent_framework_google import GoogleAIChatClient
146
+
147
+
asyncdefmain():
148
+
client = GoogleAIChatClient()
53
149
54
-
Once the chat client is released, usage will look like this:
150
+
messages = [
151
+
ChatMessage(role=Role.USER, text="Hello! My name is Alice."),
152
+
ChatMessage(role=Role.ASSISTANT, text="Hello Alice! Nice to meet you."),
153
+
ChatMessage(role=Role.USER, text="What's my name?")
154
+
]
155
+
156
+
response =await client.get_response(
157
+
messages=messages,
158
+
chat_options=ChatOptions()
159
+
)
160
+
161
+
print(response.messages[0].text)
162
+
# Output: Your name is Alice!
163
+
164
+
# Run the async function
165
+
asyncio.run(main())
166
+
```
167
+
168
+
#### Customizing Generation Parameters
55
169
56
170
```python
57
-
# from agent_framework.google import GoogleAIChatClient
58
-
#
59
-
# # Configure via environment variables
60
-
# # GOOGLE_AI_API_KEY=your_api_key
61
-
# # GOOGLE_AI_CHAT_MODEL_ID=gemini-1.5-pro
62
-
#
63
-
# client = GoogleAIChatClient()
64
-
# agent = client.create_agent(
65
-
# name="Assistant",
66
-
# instructions="You are a helpful assistant"
67
-
# )
68
-
#
69
-
# response = await agent.run("Hello!")
70
-
# print(response.text)
171
+
import asyncio
172
+
from agent_framework import ChatMessage, Role, ChatOptions
173
+
from agent_framework_google import GoogleAIChatClient
174
+
175
+
asyncdefmain():
176
+
client = GoogleAIChatClient()
177
+
178
+
messages = [
179
+
ChatMessage(role=Role.USER, text="Generate a creative story.")
180
+
]
181
+
182
+
# Customize temperature and token limit
183
+
chat_options = ChatOptions(
184
+
temperature=0.9, # Higher for more creativity
185
+
max_tokens=500,
186
+
top_p=0.95
187
+
)
188
+
189
+
response =await client.get_response(
190
+
messages=messages,
191
+
chat_options=chat_options
192
+
)
193
+
194
+
print(response.messages[0].text)
195
+
196
+
# Run the async function
197
+
asyncio.run(main())
71
198
```
72
199
73
200
## Configuration
74
201
75
202
### Environment Variables
76
203
77
204
**Google AI:**
78
-
-`GOOGLE_AI_API_KEY`: Your Google AI API key ([Get one here](https://ai.google.dev/))
79
-
-`GOOGLE_AI_CHAT_MODEL_ID`: Model to use (e.g., `gemini-1.5-pro`, `gemini-1.5-flash`)
205
+
-`GOOGLE_AI_API_KEY`: Your Google AI API key ([Get one here](https://aistudio.google.com/app/apikey))
206
+
-`GOOGLE_AI_CHAT_MODEL_ID`: Model to use (e.g., `gemini-2.5-flash`, `gemini-2.5-pro`)
80
207
81
208
### Supported Models
82
209
83
-
-`gemini-1.5-pro`: Most capable model
84
-
-`gemini-1.5-flash`: Faster, cost-effective model
85
-
-`gemini-2.0-flash-exp`: Experimental latest model
210
+
-`gemini-2.5-flash`: Best price-performance, recommended for most use cases (stable)
211
+
-`gemini-2.5-pro`: Advanced thinking model for complex reasoning (stable)
212
+
-`gemini-2.0-flash`: Previous generation workhorse model (stable)
213
+
-`gemini-1.5-pro`: Legacy stable model
214
+
-`gemini-1.5-flash`: Legacy fast model
86
215
87
216
## Features
88
217
89
-
### Planned Features
218
+
### Current Features
90
219
- ✅ Chat completion (streaming and non-streaming)
91
-
- ✅ Function/tool calling
92
-
- ✅ Multi-modal support (text, images, video, audio)
> **Note**: Vertex AI support may be added in a future iteration based on user demand.
234
+
## Development Status
106
235
107
-
## Examples
236
+
This package is being developed incrementally:
108
237
109
-
Examples will be available once the chat client is implemented. Check back soon or watch the [repository](https://github.com/microsoft/agent-framework) for updates.
238
+
- ✅ **Phase 1**: Package structure and settings classes
239
+
- ✅ **Phase 2**: Google AI chat client with streaming, function calling, and multi-modal support
0 commit comments