diff --git a/README.md b/README.md index dfdf896922..30d9ab2bdd 100644 --- a/README.md +++ b/README.md @@ -119,22 +119,35 @@ if __name__ == "__main__": ### Basic Agent - .NET +Create a simple Agent, using OpenAI Responses, that writes a haiku about the Microsoft Agent Framework + +```c# +// dotnet add package Microsoft.Agents.AI.OpenAI --prerelease +using System; +using OpenAI; + +// Replace the with your OpenAI API key. +var agent = new OpenAIClient("") + .GetOpenAIResponseClient("gpt-4o-mini") + .CreateAIAgent(name: "HaikuBot", instructions: "You are an upbeat assistant that writes beautifully."); + +Console.WriteLine(await agent.RunAsync("Write a haiku about Microsoft Agent Framework.")); +``` + +Create a simple Agent, using Azure OpenAI Responses with token based auth, that writes a haiku about the Microsoft Agent Framework + ```c# // dotnet add package Microsoft.Agents.AI.OpenAI --prerelease -// dotnet add package Azure.AI.OpenAI // dotnet add package Azure.Identity // Use `az login` to authenticate with Azure CLI using System; -using Azure.AI.OpenAI; -using Azure.Identity; -using Microsoft.Agents.AI; using OpenAI; -var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!; -var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME")!; - -var agent = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential()) - .GetOpenAIResponseClient(deploymentName) +// Replace and gpt-4o-mini with your Azure OpenAI resource name and deployment name. +var agent = new OpenAIClient( + new BearerTokenPolicy(new AzureCliCredential(), "https://ai.azure.com/.default"), + new OpenAIClientOptions() { Endpoint = new Uri("https://.openai.azure.com/openai/v1") }) + .GetOpenAIResponseClient("gpt-4o-mini") .CreateAIAgent(name: "HaikuBot", instructions: "You are an upbeat assistant that writes beautifully."); Console.WriteLine(await agent.RunAsync("Write a haiku about Microsoft Agent Framework."));