October 1st, 2024

Announcing the stable release of the Azure OpenAI library for .NET

Angelos Petropoulos
Product Manager

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.

Next steps

Here’s how you can get involved:

Author

Angelos Petropoulos
Product Manager

PM on the Azure SDK team. Originally from Greece, now in Chicago.

0 comments