Today, the OpenAI team announced their first stable release of the official OpenAI library for .NET. To go along with it, today we’re also releasing the stable release version of its companion Azure OpenAI library for .NET.
Chat client code snippet:
using OpenAI.Chat;
using Azure.AI.OpenAI;
using Azure.Identity;
AzureOpenAIClient azureClient = new(
new Uri("https://your-azure-openai-resource.com"),
new DefaultAzureCredential());
ChatClient chatClient = azureClient.GetChatClient("my-gpt-4o-deployment");
ChatCompletion completion = chatClient.CompleteChat(
[
// System messages represent instructions or other guidance about how the assistant should behave
new SystemChatMessage("You are a helpful assistant that talks like a pirate."),
// User messages represent user input, whether historical or the most recent input
new UserChatMessage("Hi, can you help me?"),
// Assistant messages in a request represent conversation history for responses
new AssistantChatMessage("Arrr! Of course, me hearty! What can I do for ye?"),
new UserChatMessage("What's the best way to train a parrot?"),
]);
Console.WriteLine($"{completion.Role}: {completion.Content[0].Text}");
Additional authentication options
For alternative authentication options, see Authenticate the client.2.1.0-beta.1 with OpenAI Realtime API support also available
We have also shipped 2.1.0-beta.1, which comes with support for the new OpenAI Realtime API just announced.
- Added a newÂ
RealtimeConversationClient
in a corresponding scenario namespace.- This maps to the newÂ
/realtime
 beta endpoint and is thus marked with a newÂ[Experimental("OPENAI002")]
 diagnostic tag. - This is a very early version of the convenience surface and thus subject to significant change
- Documentation and samples will arrive soon; in the interim, see the scenario test files for basic usage
- You can also find an external sample employing this client, together with Azure OpenAI support, at https://github.com/Azure-Samples/aoai-realtime-audio-sdk/tree/main/dotnet/samples/console
- This maps to the newÂ
Next steps
Here’s how you can get involved:
- Try the library: Install the Azure OpenAI library for .NET and start experimenting with its features or work through one of the Azure samples.
- Join the community: Engage with us and other developers on GitHub. Share your experiences, report issues, and contribute to discussions.
0 comments
Be the first to start the discussion.