Files
agent-framework/dotnet/samples/GettingStarted/AgentWithOpenAI/Agent_OpenAI_Step04_CreateFromOpenAIResponseClient
T
Stephen Toub 3c322c91e7 .NET: Update to latest Azure.AI.*, OpenAI, and M.E.AI* (#2850)
* Update to latest Azure.AI.*, OpenAI, and M.E.AI*

Absorb breaking changes in Responses surface area

* Update dotnet/samples/AgentWebChat/AgentWebChat.AgentHost/Utilities/ChatClientExtensions.cs

* Update dotnet/samples/AgentWebChat/AgentWebChat.AgentHost/Utilities/ChatClientExtensions.cs

* Update dotnet/samples/AgentWebChat/AgentWebChat.AgentHost/Utilities/ChatClientExtensions.cs

* Update dotnet/samples/GettingStarted/AgentWithOpenAI/Agent_OpenAI_Step04_CreateFromOpenAIResponseClient/Program.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Using patch to remove the model is necessary, updated the response client to actually use the the ForAgent

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
3c322c91e7 ยท 2025-12-16 12:41:20 +00:00
History
..

Creating an Agent from an OpenAIResponseClient

This sample demonstrates how to create an AI agent directly from an OpenAI.Responses.OpenAIResponseClient instance using the OpenAIResponseClientAgent class.

What This Sample Shows

  • Direct OpenAIResponseClient Creation: Shows how to create an OpenAI.Responses.OpenAIResponseClient from OpenAI.OpenAIClient and then use it to instantiate an agent
  • OpenAIResponseClientAgent: 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

  1. Set the required environment variables:

    set OPENAI_API_KEY=your_api_key_here
    set OPENAI_MODEL=gpt-4o-mini
    
  2. Run the sample:

    dotnet run