mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
51721bd9f6
* add samples for OpenAIChatClientAgent and OpenAIResponseClientAgent * Update dotnet/samples/GettingStarted/AgentWithOpenAI/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dotnet/samples/GettingStarted/AgentWithOpenAI/Agent_OpenAI_Step03_CreateFromChatClient/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dotnet/samples/GettingStarted/AgentWithOpenAI/Agent_OpenAI_Step03_CreateFromChatClient/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
51721bd9f6
ยท
2025-12-05 11:03:59 +00:00
History
Creating an Agent from a ChatClient
This sample demonstrates how to create an AI agent directly from an OpenAI.Chat.ChatClient instance using the OpenAIChatClientAgent class.
What This Sample Shows
- Direct ChatClient Creation: Shows how to create an
OpenAI.Chat.ChatClientfromOpenAI.OpenAIClientand then use it to instantiate an agent - OpenAIChatClientAgent: Demonstrates using the OpenAI SDK primitives instead of the ones from Microsoft.Extensions.AI and Microsoft.Agents.AI abstractions
- Full Agent Capabilities: Shows both regular and streaming invocation of the agent
Running the Sample
-
Set the required environment variables:
set OPENAI_API_KEY=your_api_key_here set OPENAI_MODEL=gpt-4o-mini -
Run the sample:
dotnet run