diff --git a/generated-snippets/csharp/chat-completion/entra/Sample.cs b/generated-snippets/csharp/chat-completion/entra/Sample.cs
new file mode 100644
index 0000000..14e634a
--- /dev/null
+++ b/generated-snippets/csharp/chat-completion/entra/Sample.cs
@@ -0,0 +1,42 @@
+using Azure.Identity;
+using OpenAI;
+using OpenAI.Chat;
+using System.ClientModel.Primitives;
+
+#pragma warning disable OPENAI001
+
+var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT_NAME environment variable is not set.");
+var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT environment variable is not set.");
+
+BearerTokenPolicy tokenPolicy = new(
+ new DefaultAzureCredential(),
+ "https://cognitiveservices.azure.com/.default");
+
+ChatClient client = new(
+ authenticationPolicy: tokenPolicy,
+ model: deploymentName,
+ options: new OpenAIClientOptions()
+ {
+ Endpoint = new($"{endpoint}"),
+ });
+
+ChatCompletionOptions options = new ChatCompletionOptions{
+ Temperature=(float)0.7,
+};
+
+ChatCompletion completion = client.CompleteChat(
+ [
+ new SystemChatMessage("You are a helpful assistant that talks like a pirate."),
+ new UserChatMessage("Hi, can you help me?"),
+ new AssistantChatMessage("Arrr! Of course, me hearty! What can I do for ye?"),
+ new UserChatMessage("What's the best way to train a parrot?"),
+ ], options);
+
+Console.WriteLine($"Model={completion.Model}");
+foreach (ChatMessageContentPart contentPart in completion.Content)
+{
+ string message = contentPart.Text;
+ Console.WriteLine($"Chat Role: {completion.Role}");
+ Console.WriteLine("Message:");
+ Console.WriteLine(message);
+}
diff --git a/generated-snippets/csharp/chat-completion/entra/Sample.csproj b/generated-snippets/csharp/chat-completion/entra/Sample.csproj
new file mode 100644
index 0000000..1e41ec8
--- /dev/null
+++ b/generated-snippets/csharp/chat-completion/entra/Sample.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/csharp/chat-completion/keyAuth/Sample.cs b/generated-snippets/csharp/chat-completion/keyAuth/Sample.cs
new file mode 100644
index 0000000..1bf95f9
--- /dev/null
+++ b/generated-snippets/csharp/chat-completion/keyAuth/Sample.cs
@@ -0,0 +1,36 @@
+using OpenAI;
+using OpenAI.Chat;
+using System.ClientModel;
+
+#pragma warning disable OPENAI001
+
+var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT_NAME environment variable is not set.");
+var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT environment variable is not set.");
+var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? throw new InvalidOperationException("AZURE_OPENAI_API_KEY environment variable is not set.");
+
+
+ChatClient client = new(
+ credential: new ApiKeyCredential(apiKey),
+ model: deploymentName,
+ options: new OpenAIClientOptions()
+ {
+ Endpoint = new($"{endpoint}"),
+ });
+
+
+ChatCompletion completion = client.CompleteChat(
+ [
+ new SystemChatMessage("You are a helpful assistant that talks like a pirate."),
+ new UserChatMessage("Hi, can you help me?"),
+ 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($"Model={completion.Model}");
+foreach (ChatMessageContentPart contentPart in completion.Content)
+{
+ string message = contentPart.Text;
+ Console.WriteLine($"Chat Role: {completion.Role}");
+ Console.WriteLine("Message:");
+ Console.WriteLine(message);
+}
diff --git a/generated-snippets/csharp/chat-completion/keyAuth/Sample.csproj b/generated-snippets/csharp/chat-completion/keyAuth/Sample.csproj
new file mode 100644
index 0000000..1e41ec8
--- /dev/null
+++ b/generated-snippets/csharp/chat-completion/keyAuth/Sample.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/csharp/chat-responses/entra/Sample.cs b/generated-snippets/csharp/chat-responses/entra/Sample.cs
new file mode 100644
index 0000000..3f74559
--- /dev/null
+++ b/generated-snippets/csharp/chat-responses/entra/Sample.cs
@@ -0,0 +1,32 @@
+using Azure.Identity;
+using OpenAI;
+using OpenAI.Responses;
+using System.ClientModel.Primitives;
+
+#pragma warning disable OPENAI001
+
+var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT_NAME environment variable is not set.");
+var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT environment variable is not set.");
+
+BearerTokenPolicy tokenPolicy = new(
+ new DefaultAzureCredential(),
+ "https://cognitiveservices.azure.com/.default");
+
+OpenAIResponseClient client = new(
+ model: deploymentName,
+ authenticationPolicy: tokenPolicy,
+ options: new OpenAIClientOptions()
+ {
+ Endpoint = new($"{endpoint}"),
+ });
+
+ResponseCreationOptions options = new ResponseCreationOptions{
+ Temperature=(float)0.7,
+};
+
+OpenAIResponse response = client.CreateResponse(
+ [
+ ResponseItem.CreateUserMessageItem("What's the weather like today for my current location?"),
+ ], options);
+
+Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}");
diff --git a/generated-snippets/csharp/chat-responses/entra/Sample.csproj b/generated-snippets/csharp/chat-responses/entra/Sample.csproj
new file mode 100644
index 0000000..1e41ec8
--- /dev/null
+++ b/generated-snippets/csharp/chat-responses/entra/Sample.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/csharp/chat-responses/keyAuth/Sample.cs b/generated-snippets/csharp/chat-responses/keyAuth/Sample.cs
new file mode 100644
index 0000000..eb797c5
--- /dev/null
+++ b/generated-snippets/csharp/chat-responses/keyAuth/Sample.cs
@@ -0,0 +1,28 @@
+using OpenAI;
+using OpenAI.Responses;
+using System.ClientModel;
+
+#pragma warning disable OPENAI001
+
+var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT_NAME environment variable is not set.");
+var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT environment variable is not set.");
+var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? throw new InvalidOperationException("AZURE_OPENAI_API_KEY environment variable is not set.");
+
+OpenAIResponseClient client = new(
+ model: deploymentName,
+ credential: new ApiKeyCredential(apiKey),
+ options: new OpenAIClientOptions()
+ {
+ Endpoint = new($"{endpoint}"),
+ });
+
+ResponseCreationOptions options = new ResponseCreationOptions{
+ Temperature=(float)0.7,
+};
+
+OpenAIResponse response = client.CreateResponse(
+ [
+ ResponseItem.CreateUserMessageItem("What's the weather like today for my current location?"),
+ ], options);
+
+Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}");
diff --git a/generated-snippets/csharp/chat-responses/keyAuth/Sample.csproj b/generated-snippets/csharp/chat-responses/keyAuth/Sample.csproj
new file mode 100644
index 0000000..1e41ec8
--- /dev/null
+++ b/generated-snippets/csharp/chat-responses/keyAuth/Sample.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/csharp/images/entra/Sample.cs b/generated-snippets/csharp/images/entra/Sample.cs
new file mode 100644
index 0000000..9fcf906
--- /dev/null
+++ b/generated-snippets/csharp/images/entra/Sample.cs
@@ -0,0 +1,35 @@
+using Azure.Identity;
+using OpenAI;
+using OpenAI.Images;
+using System;
+using System.IO;
+using System.ClientModel.Primitives;
+
+#pragma warning disable OPENAI001
+
+var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT environment variable is not set.");
+var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT_NAME environment variable is not set.");
+BearerTokenPolicy tokenPolicy = new(
+ new DefaultAzureCredential(),
+ "https://cognitiveservices.azure.com/.default");
+
+ImageClient client = new(
+ authenticationPolicy: tokenPolicy,
+ model: deploymentName,
+ options: new OpenAIClientOptions()
+ {
+ Endpoint = new($"{endpoint}"),
+ });
+
+string prompt = "A cute baby polar bear";
+
+ImageGenerationOptions options = new()
+{
+ Size = GeneratedImageSize.W1024xH1024,
+};
+
+GeneratedImage image = client.GenerateImage(prompt, options);
+BinaryData bytes = image.ImageBytes;
+
+using FileStream stream = File.OpenWrite("output.png");
+bytes.ToStream().CopyTo(stream);
\ No newline at end of file
diff --git a/generated-snippets/csharp/images/entra/Sample.csproj b/generated-snippets/csharp/images/entra/Sample.csproj
new file mode 100644
index 0000000..2420eb9
--- /dev/null
+++ b/generated-snippets/csharp/images/entra/Sample.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/csharp/images/keyAuth/Sample.cs b/generated-snippets/csharp/images/keyAuth/Sample.cs
new file mode 100644
index 0000000..cd81a50
--- /dev/null
+++ b/generated-snippets/csharp/images/keyAuth/Sample.cs
@@ -0,0 +1,34 @@
+using Azure;
+using OpenAI;
+using OpenAI.Images;
+using System;
+using System.IO;
+using System.ClientModel;
+
+#pragma warning disable OPENAI001
+
+var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT environment variable is not set.");
+var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT_NAME environment variable is not set.");
+var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? throw new InvalidOperationException("AZURE_OPENAI_API_KEY environment variable is not set.");;
+
+ImageClient client = new(
+ credential: new ApiKeyCredential(apiKey),
+ model: deploymentName,
+ options: new OpenAIClientOptions()
+ {
+ Endpoint = new($"{endpoint}"),
+ }
+);
+
+string prompt = "A cute baby polar bear";
+
+ImageGenerationOptions options = new()
+{
+ Size = GeneratedImageSize.W1024xH1024,
+};
+
+GeneratedImage image = client.GenerateImage(prompt, options);
+BinaryData bytes = image.ImageBytes;
+
+using FileStream stream = File.OpenWrite("output.png");
+bytes.ToStream().CopyTo(stream);
\ No newline at end of file
diff --git a/generated-snippets/csharp/images/keyAuth/Sample.csproj b/generated-snippets/csharp/images/keyAuth/Sample.csproj
new file mode 100644
index 0000000..2420eb9
--- /dev/null
+++ b/generated-snippets/csharp/images/keyAuth/Sample.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/go/chat-completion/entra/go.mod b/generated-snippets/go/chat-completion/entra/go.mod
new file mode 100644
index 0000000..d5cdbca
--- /dev/null
+++ b/generated-snippets/go/chat-completion/entra/go.mod
@@ -0,0 +1,8 @@
+module sample
+
+go 1.24.3
+
+require (
+ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0
+ github.com/openai/openai-go/v3 v3.0.0
+)
diff --git a/generated-snippets/go/chat-completion/entra/sample.go b/generated-snippets/go/chat-completion/entra/sample.go
new file mode 100644
index 0000000..1f5417b
--- /dev/null
+++ b/generated-snippets/go/chat-completion/entra/sample.go
@@ -0,0 +1,67 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "log"
+ "os"
+
+ "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
+ "github.com/openai/openai-go/v2"
+ "github.com/openai/openai-go/v2/azure"
+ "github.com/openai/openai-go/v2/option"
+)
+
+func main() {
+ endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT")
+ if len(endpoint) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+ os.Exit(1)
+ }
+ deploymentName := os.Getenv("AZURE_OPENAI_DEPLOYMENT")
+ if len(deploymentName) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+ os.Exit(1)
+ }
+
+ token_credential, err := azidentity.NewDefaultAzureCredential(nil)
+ if err != nil {
+ fmt.Println("Error creating credential:", err)
+ os.Exit(1)
+ }
+ client := openai.NewClient(
+ option.WithBaseURL(endpoint),
+ azure.WithTokenCredential(token_credential),
+ )
+
+ resp, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
+ Model: openai.ChatModel(deploymentName),
+ Messages: []openai.ChatCompletionMessageParamUnion{
+ {
+ OfSystem: &openai.ChatCompletionSystemMessageParam{
+ Content: openai.ChatCompletionSystemMessageParamContentUnion{
+ OfString: openai.String("You are a helpful assistant. You will talk like a pirate."),
+ },
+ },
+ },
+ {
+ OfUser: &openai.ChatCompletionUserMessageParam{
+ Content: openai.ChatCompletionUserMessageParamContentUnion{
+ OfString: openai.String("What's the best way to train a parrot?"),
+ },
+ },
+ },
+ },
+ })
+
+ if err != nil {
+ log.Printf("ERROR: %s", err)
+ return
+ }
+
+ for _, choice := range resp.Choices {
+ if choice.Message.Content != "" {
+ fmt.Fprintf(os.Stderr, "Content[%d]: %s\n", choice.Index, choice.Message.Content)
+ }
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/go/chat-completion/keyAuth/go.mod b/generated-snippets/go/chat-completion/keyAuth/go.mod
new file mode 100644
index 0000000..d5cdbca
--- /dev/null
+++ b/generated-snippets/go/chat-completion/keyAuth/go.mod
@@ -0,0 +1,8 @@
+module sample
+
+go 1.24.3
+
+require (
+ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0
+ github.com/openai/openai-go/v3 v3.0.0
+)
diff --git a/generated-snippets/go/chat-completion/keyAuth/sample.go b/generated-snippets/go/chat-completion/keyAuth/sample.go
new file mode 100644
index 0000000..84cd256
--- /dev/null
+++ b/generated-snippets/go/chat-completion/keyAuth/sample.go
@@ -0,0 +1,65 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "log"
+ "os"
+
+ "github.com/openai/openai-go/v2"
+ "github.com/openai/openai-go/v2/option"
+)
+
+func main() {
+ endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT")
+ if len(endpoint) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+ os.Exit(1)
+ }
+ apiKey := os.Getenv("AZURE_OPENAI_API_KEY")
+ if len(apiKey) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_API_KEY environment variable.")
+ os.Exit(1)
+ }
+ deploymentName := os.Getenv("AZURE_OPENAI_DEPLOYMENT")
+ if len(deploymentName) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+ os.Exit(1)
+ }
+
+ client := openai.NewClient(
+ option.WithBaseURL(endpoint),
+ option.WithAPIKey(apiKey),
+ )
+
+ resp, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
+ Model: openai.ChatModel(deploymentName),
+ Messages: []openai.ChatCompletionMessageParamUnion{
+ {
+ OfSystem: &openai.ChatCompletionSystemMessageParam{
+ Content: openai.ChatCompletionSystemMessageParamContentUnion{
+ OfString: openai.String("You are a helpful assistant. You will talk like a pirate."),
+ },
+ },
+ },
+ {
+ OfUser: &openai.ChatCompletionUserMessageParam{
+ Content: openai.ChatCompletionUserMessageParamContentUnion{
+ OfString: openai.String("What's the best way to train a parrot?"),
+ },
+ },
+ },
+ },
+ })
+
+ if err != nil {
+ log.Printf("ERROR: %s", err)
+ return
+ }
+
+ for _, choice := range resp.Choices {
+ if choice.Message.Content != "" {
+ fmt.Fprintf(os.Stderr, "Content[%d]: %s\n", choice.Index, choice.Message.Content)
+ }
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/go/chat-responses/entra/go.mod b/generated-snippets/go/chat-responses/entra/go.mod
new file mode 100644
index 0000000..d5cdbca
--- /dev/null
+++ b/generated-snippets/go/chat-responses/entra/go.mod
@@ -0,0 +1,8 @@
+module sample
+
+go 1.24.3
+
+require (
+ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0
+ github.com/openai/openai-go/v3 v3.0.0
+)
diff --git a/generated-snippets/go/chat-responses/entra/sample.go b/generated-snippets/go/chat-responses/entra/sample.go
new file mode 100644
index 0000000..6dc31d6
--- /dev/null
+++ b/generated-snippets/go/chat-responses/entra/sample.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+ "context"
+
+ "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
+ "github.com/openai/openai-go/v3"
+ "github.com/openai/openai-go/v3/azure"
+ "github.com/openai/openai-go/v3/option"
+ "github.com/openai/openai-go/v3/responses"
+)
+
+func main() {
+ endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT")
+ if len(endpoint) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+ os.Exit(1)
+ }
+ deploymentName := os.Getenv("AZURE_OPENAI_DEPLOYMENT")
+ if len(deploymentName) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+ os.Exit(1)
+ }
+
+ token_credential, err := azidentity.NewDefaultAzureCredential(nil)
+ if err != nil {
+ println("Error creating credential.")
+ panic(err)
+ }
+
+ client := openai.NewClient(
+ option.WithBaseURL(endpoint),
+ azure.WithTokenCredential(token_credential),
+ )
+ ctx := context.Background()
+
+ question := "Write me a haiku about computers"
+
+ resp, err := client.Responses.New(ctx, responses.ResponseNewParams{
+ Input: responses.ResponseNewParamsInputUnion{OfString: openai.String(question)},
+ Model: deploymentName,
+ })
+
+ if err != nil {
+ panic(err)
+ }
+
+ println(resp.OutputText())
+}
diff --git a/generated-snippets/go/chat-responses/keyAuth/go.mod b/generated-snippets/go/chat-responses/keyAuth/go.mod
new file mode 100644
index 0000000..d5cdbca
--- /dev/null
+++ b/generated-snippets/go/chat-responses/keyAuth/go.mod
@@ -0,0 +1,8 @@
+module sample
+
+go 1.24.3
+
+require (
+ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0
+ github.com/openai/openai-go/v3 v3.0.0
+)
diff --git a/generated-snippets/go/chat-responses/keyAuth/sample.go b/generated-snippets/go/chat-responses/keyAuth/sample.go
new file mode 100644
index 0000000..6fccffc
--- /dev/null
+++ b/generated-snippets/go/chat-responses/keyAuth/sample.go
@@ -0,0 +1,46 @@
+package main
+
+import (
+ "context"
+
+ "github.com/openai/openai-go/v3"
+ "github.com/openai/openai-go/v3/option"
+ "github.com/openai/openai-go/v3/responses"
+)
+
+func main() {
+ endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT")
+ if len(endpoint) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+ os.Exit(1)
+ }
+ apiKey := os.Getenv("AZURE_OPENAI_API_KEY")
+ if len(apiKey) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_API_KEY environment variable.")
+ os.Exit(1)
+ }
+ deploymentName := os.Getenv("AZURE_OPENAI_DEPLOYMENT")
+ if len(deploymentName) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+ os.Exit(1)
+ }
+
+ client := openai.NewClient(
+ option.WithBaseURL(endpoint),
+ option.WithAPIKey(apiKey),
+ )
+ ctx := context.Background()
+
+ question := "Write me a haiku about computers"
+
+ resp, err := client.Responses.New(ctx, responses.ResponseNewParams{
+ Input: responses.ResponseNewParamsInputUnion{OfString: openai.String(question)},
+ Model: deploymentName,
+ })
+
+ if err != nil {
+ panic(err)
+ }
+
+ println(resp.OutputText())
+}
diff --git a/generated-snippets/go/images/entra/go.mod b/generated-snippets/go/images/entra/go.mod
new file mode 100644
index 0000000..4ab97f9
--- /dev/null
+++ b/generated-snippets/go/images/entra/go.mod
@@ -0,0 +1,8 @@
+module sample
+
+go 1.24.3
+
+require (
+ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.12.0
+ github.com/openai/openai-go/v2 v2.7.0
+)
diff --git a/generated-snippets/go/images/entra/sample.go b/generated-snippets/go/images/entra/sample.go
new file mode 100644
index 0000000..cc79453
--- /dev/null
+++ b/generated-snippets/go/images/entra/sample.go
@@ -0,0 +1,57 @@
+package main
+
+import (
+ "context"
+ "encoding/base64"
+ "os"
+
+ "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
+ "github.com/openai/openai-go/v2"
+ "github.com/openai/openai-go/v2/azure"
+ "github.com/openai/openai-go/v2/option"
+)
+
+func main() {
+ endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT")
+ if len(endpoint) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+ os.Exit(1)
+ }
+ deploymentName := os.Getenv("AZURE_OPENAI_DEPLOYMENT")
+ if len(deploymentName) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+ os.Exit(1)
+ }
+
+ token_credential, err := azidentity.NewDefaultAzureCredential(nil)
+ if err != nil {
+ panic(err)
+ }
+ client := openai.NewClient(
+ option.WithBaseURL(endpoint),
+ azure.WithTokenCredential(token_credential),
+ )
+
+ // Generate an image
+ image, err := client.Images.Generate(context.Background(), openai.ImageGenerateParams{
+ Prompt: "A cute baby polar bear",
+ Model: deploymentName,
+ N: openai.Int(1),
+ })
+ if err != nil {
+ panic(err)
+ }
+
+ // Save the image to a file
+ imageBytes, err := base64.StdEncoding.DecodeString(image.Data[0].B64JSON)
+ if err != nil {
+ panic(err)
+ }
+
+ dest := "./output.png"
+ println("Writing image to " + dest)
+ err = os.WriteFile(dest, imageBytes, 0755)
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/generated-snippets/go/images/keyAuth/go.mod b/generated-snippets/go/images/keyAuth/go.mod
new file mode 100644
index 0000000..4ab97f9
--- /dev/null
+++ b/generated-snippets/go/images/keyAuth/go.mod
@@ -0,0 +1,8 @@
+module sample
+
+go 1.24.3
+
+require (
+ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.12.0
+ github.com/openai/openai-go/v2 v2.7.0
+)
diff --git a/generated-snippets/go/images/keyAuth/sample.go b/generated-snippets/go/images/keyAuth/sample.go
new file mode 100644
index 0000000..af80d5c
--- /dev/null
+++ b/generated-snippets/go/images/keyAuth/sample.go
@@ -0,0 +1,56 @@
+package main
+
+import (
+ "context"
+ "encoding/base64"
+ "os"
+
+ "github.com/openai/openai-go/v2"
+ "github.com/openai/openai-go/v2/option"
+)
+
+func main() {
+ endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT")
+ if len(endpoint) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+ os.Exit(1)
+ }
+ deploymentName := os.Getenv("AZURE_OPENAI_DEPLOYMENT")
+ if len(deploymentName) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+ os.Exit(1)
+ }
+ apiKey := os.Getenv("AZURE_OPENAI_API_KEY")
+ if len(apiKey) == 0 {
+ fmt.Println("Please set the AZURE_OPENAI_API_KEY environment variable.")
+ os.Exit(1)
+ }
+
+ client := openai.NewClient(
+ option.WithBaseURL(endpoint),
+ option.WithAPIKey(apiKey),
+ )
+
+ // Generate an image
+ image, err := client.Images.Generate(context.Background(), openai.ImageGenerateParams{
+ Prompt: "A cute baby polar bear",
+ Model: deploymentName,
+ N: openai.Int(1),
+ })
+ if err != nil {
+ panic(err)
+ }
+
+ // Save the image to a file
+ imageBytes, err := base64.StdEncoding.DecodeString(image.Data[0].B64JSON)
+ if err != nil {
+ panic(err)
+ }
+
+ dest := "./output.png"
+ println("Writing image to " + dest)
+ err = os.WriteFile(dest, imageBytes, 0755)
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/generated-snippets/java/chat-completion/entra/Sample.java b/generated-snippets/java/chat-completion/entra/Sample.java
new file mode 100644
index 0000000..df5d3df
--- /dev/null
+++ b/generated-snippets/java/chat-completion/entra/Sample.java
@@ -0,0 +1,49 @@
+import com.openai.client.OpenAIClient;
+import com.openai.client.okhttp.OpenAIOkHttpClient;
+import com.openai.models.ChatModel;
+import com.openai.models.chat.completions.ChatCompletion;
+import com.openai.models.chat.completions.ChatCompletionCreateParams;
+import com.openai.models.chat.completions.ChatCompletionMessage;
+
+import com.azure.identity.AuthenticationUtil;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.openai.credential.BearerTokenCredential;
+
+public class Sample {
+ public static void main(String[] args) {
+
+ String endpoint = System.getenv("AZURE_OPENAI_ENDPOINT");
+ if (endpoint == null || endpoint.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ System.exit(1);
+ }
+ String deploymentName = System.getenv("AZURE_OPENAI_DEPLOYMENT");
+ if (deploymentName == null || deploymentName.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ System.exit(1);
+ }
+
+ OpenAIClient client = OpenAIOkHttpClient.builder()
+ .baseUrl(endpoint)
+ // Set the Azure Entra ID
+ .credential(BearerTokenCredential.create(AuthenticationUtil.getBearerTokenSupplier(
+ new DefaultAzureCredentialBuilder().build(), "https://cognitiveservices.azure.com/.default")))
+ .build();
+
+ ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
+ .model(ChatModel.of(deploymentName))
+ .addSystemMessage("You are a helpful assistant. You will talk like a pirate.")
+ .addUserMessage("Can you help me?")
+ .addUserMessage("What's the best way to train a parrot?")
+ .build();
+
+ ChatCompletion chatCompletion = client.chat().completions().create(createParams);
+ System.out.printf("Model ID=%s is created at %s.%n", chatCompletion.id(), chatCompletion.created());
+
+ for (ChatCompletion.Choice choice : chatCompletion.choices()) {
+ ChatCompletionMessage message = choice.message();
+ System.out.println("Message:");
+ System.out.println(message.content());
+ }
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/java/chat-completion/entra/pom.xml b/generated-snippets/java/chat-completion/entra/pom.xml
new file mode 100644
index 0000000..b0e6d1a
--- /dev/null
+++ b/generated-snippets/java/chat-completion/entra/pom.xml
@@ -0,0 +1,43 @@
+
+ 4.0.0
+ sample
+ sample
+ 1.0-SNAPSHOT
+
+
+ com.openai
+ openai-java
+ 3.0.3
+
+
+ com.azure
+ azure-identity
+ 1.18.0
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.6.0
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ .
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/java/chat-completion/keyAuth/Sample.java b/generated-snippets/java/chat-completion/keyAuth/Sample.java
new file mode 100644
index 0000000..e7d0190
--- /dev/null
+++ b/generated-snippets/java/chat-completion/keyAuth/Sample.java
@@ -0,0 +1,51 @@
+import com.openai.client.OpenAIClient;
+import com.openai.client.okhttp.OpenAIOkHttpClient;
+import com.openai.models.ChatModel;
+import com.openai.models.chat.completions.ChatCompletion;
+import com.openai.models.chat.completions.ChatCompletionCreateParams;
+import com.openai.models.chat.completions.ChatCompletionMessage;
+
+import com.openai.azure.credential.AzureApiKeyCredential;
+
+
+public class Sample {
+ public static void main(String[] args) {
+
+ String endpoint = System.getenv("AZURE_OPENAI_ENDPOINT");
+ if (endpoint == null || endpoint.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ System.exit(1);
+ }
+ String apiKey = System.getenv("AZURE_OPENAI_API_KEY");
+ if (apiKey == null || apiKey.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_API_KEY environment variable.");
+ System.exit(1);
+ }
+ String deploymentName = System.getenv("AZURE_OPENAI_DEPLOYMENT");
+ if (deploymentName == null || deploymentName.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ System.exit(1);
+ }
+
+ OpenAIClient client = OpenAIOkHttpClient.builder()
+ .baseUrl(endpoint)
+ .credential(AzureApiKeyCredential.create(apiKey))
+ .build();
+
+ ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
+ .model(ChatModel.of(deploymentName))
+ .addSystemMessage("You are a helpful assistant. You will talk like a pirate.")
+ .addUserMessage("Can you help me?")
+ .addUserMessage("What's the best way to train a parrot?")
+ .build();
+
+ ChatCompletion chatCompletion = client.chat().completions().create(createParams);
+ System.out.printf("Model ID=%s is created at %s.%n", chatCompletion.id(), chatCompletion.created());
+
+ for (ChatCompletion.Choice choice : chatCompletion.choices()) {
+ ChatCompletionMessage message = choice.message();
+ System.out.println("Message:");
+ System.out.println(message.content());
+ }
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/java/chat-completion/keyAuth/pom.xml b/generated-snippets/java/chat-completion/keyAuth/pom.xml
new file mode 100644
index 0000000..b0e6d1a
--- /dev/null
+++ b/generated-snippets/java/chat-completion/keyAuth/pom.xml
@@ -0,0 +1,43 @@
+
+ 4.0.0
+ sample
+ sample
+ 1.0-SNAPSHOT
+
+
+ com.openai
+ openai-java
+ 3.0.3
+
+
+ com.azure
+ azure-identity
+ 1.18.0
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.6.0
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ .
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/java/chat-responses/entra/Sample.java b/generated-snippets/java/chat-responses/entra/Sample.java
new file mode 100644
index 0000000..f60b024
--- /dev/null
+++ b/generated-snippets/java/chat-responses/entra/Sample.java
@@ -0,0 +1,43 @@
+import com.openai.client.OpenAIClient;
+import com.openai.client.okhttp.OpenAIOkHttpClient;
+import com.openai.models.ChatModel;
+import com.openai.models.responses.ResponseCreateParams;
+
+import com.azure.identity.AuthenticationUtil;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.openai.credential.BearerTokenCredential;
+public class Sample {
+ public static void main(String[] args) {
+
+ String endpoint = System.getenv("AZURE_OPENAI_ENDPOINT");
+ if (endpoint == null || endpoint.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ System.exit(1);
+ }
+ String deploymentName = System.getenv("AZURE_OPENAI_DEPLOYMENT");
+ if (deploymentName == null || deploymentName.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ System.exit(1);
+ }
+
+ OpenAIClient client = OpenAIOkHttpClient.builder()
+ .baseUrl(endpoint)
+ // Set the Azure Entra ID
+ .credential(BearerTokenCredential.create(AuthenticationUtil.getBearerTokenSupplier(
+ new DefaultAzureCredentialBuilder().build(), "https://cognitiveservices.azure.com/.default")))
+ .build();
+
+ ResponseCreateParams.Builder paramsBuilder = ResponseCreateParams.builder()
+ .model(deploymentName)
+ .input("What's the capital of France?");
+
+
+ ResponseCreateParams createParams = paramsBuilder.build();
+
+ client.responses().create(createParams).output().stream()
+ .flatMap(item -> item.message().stream())
+ .flatMap(message -> message.content().stream())
+ .flatMap(content -> content.outputText().stream())
+ .forEach(outputText -> System.out.println(outputText.text()));
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/java/chat-responses/entra/pom.xml b/generated-snippets/java/chat-responses/entra/pom.xml
new file mode 100644
index 0000000..b0e6d1a
--- /dev/null
+++ b/generated-snippets/java/chat-responses/entra/pom.xml
@@ -0,0 +1,43 @@
+
+ 4.0.0
+ sample
+ sample
+ 1.0-SNAPSHOT
+
+
+ com.openai
+ openai-java
+ 3.0.3
+
+
+ com.azure
+ azure-identity
+ 1.18.0
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.6.0
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ .
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/java/chat-responses/keyAuth/Sample.java b/generated-snippets/java/chat-responses/keyAuth/Sample.java
new file mode 100644
index 0000000..6327b32
--- /dev/null
+++ b/generated-snippets/java/chat-responses/keyAuth/Sample.java
@@ -0,0 +1,45 @@
+import com.openai.client.OpenAIClient;
+import com.openai.client.okhttp.OpenAIOkHttpClient;
+import com.openai.models.ChatModel;
+import com.openai.models.responses.ResponseCreateParams;
+
+import com.openai.azure.credential.AzureApiKeyCredential;
+
+public class Sample {
+ public static void main(String[] args) {
+
+ String endpoint = System.getenv("AZURE_OPENAI_ENDPOINT");
+ if (endpoint == null || endpoint.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ System.exit(1);
+ }
+ String apiKey = System.getenv("AZURE_OPENAI_API_KEY");
+ if (apiKey == null || apiKey.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_API_KEY environment variable.");
+ System.exit(1);
+ }
+ String deploymentName = System.getenv("AZURE_OPENAI_DEPLOYMENT");
+ if (deploymentName == null || deploymentName.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ System.exit(1);
+ }
+
+ OpenAIClient client = OpenAIOkHttpClient.builder()
+ .baseUrl(endpoint)
+ .credential(AzureApiKeyCredential.create(apiKey))
+ .build();
+
+ ResponseCreateParams.Builder paramsBuilder = ResponseCreateParams.builder()
+ .model(deploymentName)
+ .input("What's the capital of France?");
+
+
+ ResponseCreateParams createParams = paramsBuilder.build();
+
+ client.responses().create(createParams).output().stream()
+ .flatMap(item -> item.message().stream())
+ .flatMap(message -> message.content().stream())
+ .flatMap(content -> content.outputText().stream())
+ .forEach(outputText -> System.out.println(outputText.text()));
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/java/chat-responses/keyAuth/pom.xml b/generated-snippets/java/chat-responses/keyAuth/pom.xml
new file mode 100644
index 0000000..b0e6d1a
--- /dev/null
+++ b/generated-snippets/java/chat-responses/keyAuth/pom.xml
@@ -0,0 +1,43 @@
+
+ 4.0.0
+ sample
+ sample
+ 1.0-SNAPSHOT
+
+
+ com.openai
+ openai-java
+ 3.0.3
+
+
+ com.azure
+ azure-identity
+ 1.18.0
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.6.0
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ .
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/java/images/entra/Sample.java b/generated-snippets/java/images/entra/Sample.java
new file mode 100644
index 0000000..973c32b
--- /dev/null
+++ b/generated-snippets/java/images/entra/Sample.java
@@ -0,0 +1,52 @@
+import com.openai.client.OpenAIClient;
+import com.openai.client.okhttp.OpenAIOkHttpClient;
+import com.openai.models.images.ImageGenerateParams;
+import com.openai.models.images.ImageModel;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Base64;
+
+import com.azure.identity.AuthenticationUtil;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.openai.credential.BearerTokenCredential;
+
+public class Sample {
+ public static void main(String[] args) {
+
+ String endpoint = System.getenv("AZURE_OPENAI_ENDPOINT");
+ if (endpoint == null || endpoint.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ System.exit(1);
+ }
+ String deploymentName = System.getenv("AZURE_OPENAI_DEPLOYMENT");
+ if (deploymentName == null || deploymentName.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ System.exit(1);
+ }
+
+ OpenAIClient client = OpenAIOkHttpClient.builder()
+ .baseUrl(endpoint)
+ // Set the Azure Entra ID
+ .credential(BearerTokenCredential.create(AuthenticationUtil.getBearerTokenSupplier(
+ new DefaultAzureCredentialBuilder().build(), "https://cognitiveservices.azure.com/.default")))
+ .build();
+
+ ImageGenerateParams imageGenerateParams = ImageGenerateParams.builder()
+ .prompt("A cute baby polar bear")
+ .model(deploymentName)
+ .n(1)
+ .build();
+
+ client.images().generate(imageGenerateParams).data().orElseThrow().forEach(image -> {
+ try {
+ String base64String = image.b64Json().orElseThrow();
+ byte[] imageData = Base64.getDecoder().decode(base64String);
+ Files.write(Paths.get("output.png"), imageData);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/java/images/entra/pom.xml b/generated-snippets/java/images/entra/pom.xml
new file mode 100644
index 0000000..ad9dbdc
--- /dev/null
+++ b/generated-snippets/java/images/entra/pom.xml
@@ -0,0 +1,43 @@
+
+ 4.0.0
+ sample
+ sample
+ 1.0-SNAPSHOT
+
+
+ com.openai
+ openai-java
+ 3.7.1
+
+
+ com.azure
+ azure-identity
+ 1.18.0
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.6.0
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ .
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/java/images/keyAuth/Sample.java b/generated-snippets/java/images/keyAuth/Sample.java
new file mode 100644
index 0000000..712178a
--- /dev/null
+++ b/generated-snippets/java/images/keyAuth/Sample.java
@@ -0,0 +1,54 @@
+import com.openai.client.OpenAIClient;
+import com.openai.client.okhttp.OpenAIOkHttpClient;
+import com.openai.models.images.ImageGenerateParams;
+import com.openai.models.images.ImageModel;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Base64;
+
+import com.openai.azure.credential.AzureApiKeyCredential;
+
+
+public class Sample {
+ public static void main(String[] args) {
+
+ String endpoint = System.getenv("AZURE_OPENAI_ENDPOINT");
+ if (endpoint == null || endpoint.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ System.exit(1);
+ }
+ String deploymentName = System.getenv("AZURE_OPENAI_DEPLOYMENT");
+ if (deploymentName == null || deploymentName.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ System.exit(1);
+ }
+ String apiKey = System.getenv("AZURE_OPENAI_API_KEY");
+ if (apiKey == null || apiKey.isEmpty()) {
+ System.out.println("Please set the AZURE_OPENAI_API_KEY environment variable.");
+ System.exit(1);
+ }
+
+ OpenAIClient client = OpenAIOkHttpClient.builder()
+ .baseUrl(endpoint)
+ .credential(AzureApiKeyCredential.create(apiKey))
+ .build();
+
+ ImageGenerateParams imageGenerateParams = ImageGenerateParams.builder()
+ .prompt("A cute baby polar bear")
+ .model(deploymentName)
+ .n(1)
+ .build();
+
+ client.images().generate(imageGenerateParams).data().orElseThrow().forEach(image -> {
+ try {
+ String base64String = image.b64Json().orElseThrow();
+ byte[] imageData = Base64.getDecoder().decode(base64String);
+ Files.write(Paths.get("output.png"), imageData);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/generated-snippets/java/images/keyAuth/pom.xml b/generated-snippets/java/images/keyAuth/pom.xml
new file mode 100644
index 0000000..ad9dbdc
--- /dev/null
+++ b/generated-snippets/java/images/keyAuth/pom.xml
@@ -0,0 +1,43 @@
+
+ 4.0.0
+ sample
+ sample
+ 1.0-SNAPSHOT
+
+
+ com.openai
+ openai-java
+ 3.7.1
+
+
+ com.azure
+ azure-identity
+ 1.18.0
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.6.0
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ .
+
+
+
+
+
+
+
+
diff --git a/generated-snippets/javascript/chat-completion/entra/package.json b/generated-snippets/javascript/chat-completion/entra/package.json
new file mode 100644
index 0000000..a34b31e
--- /dev/null
+++ b/generated-snippets/javascript/chat-completion/entra/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "sample",
+ "version": "1.0.0",
+ "type": "module",
+ "dependencies": {
+ "openai": "5.19.1", "@azure/identity": "4.11.1" }
+}
diff --git a/generated-snippets/javascript/chat-completion/entra/sample.js b/generated-snippets/javascript/chat-completion/entra/sample.js
new file mode 100644
index 0000000..76c7f3c
--- /dev/null
+++ b/generated-snippets/javascript/chat-completion/entra/sample.js
@@ -0,0 +1,33 @@
+import OpenAI from "openai";
+import { getBearerTokenProvider, DefaultAzureCredential } from "@azure/identity";
+
+const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
+if (!endpoint) {
+ console.error("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ process.exit(1);
+}
+const deploymentName = process.env["AZURE_OPENAI_DEPLOYMENT"];
+if (!deploymentName) {
+ console.error("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ process.exit(1);
+}
+const tokenProvider = getBearerTokenProvider(
+ new DefaultAzureCredential(),
+ 'https://cognitiveservices.azure.com/.default');
+
+const openai = new OpenAI({
+ baseURL: endpoint,
+ apiKey: tokenProvider
+});
+
+async function main() {
+ const completion = await openai.chat.completions.create({
+ messages: [{ role: "developer", content: "You are a helpful assistant." }],
+ model: deploymentName,
+ store: true,
+ });
+
+ console.log(completion.choices[0]);
+}
+
+main();
\ No newline at end of file
diff --git a/generated-snippets/javascript/chat-completion/keyAuth/package.json b/generated-snippets/javascript/chat-completion/keyAuth/package.json
new file mode 100644
index 0000000..a34b31e
--- /dev/null
+++ b/generated-snippets/javascript/chat-completion/keyAuth/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "sample",
+ "version": "1.0.0",
+ "type": "module",
+ "dependencies": {
+ "openai": "5.19.1", "@azure/identity": "4.11.1" }
+}
diff --git a/generated-snippets/javascript/chat-completion/keyAuth/sample.js b/generated-snippets/javascript/chat-completion/keyAuth/sample.js
new file mode 100644
index 0000000..5f6cd62
--- /dev/null
+++ b/generated-snippets/javascript/chat-completion/keyAuth/sample.js
@@ -0,0 +1,34 @@
+import OpenAI from "openai";
+
+const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
+if (!endpoint) {
+ console.error("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ process.exit(1);
+}
+const deploymentName = process.env["AZURE_OPENAI_DEPLOYMENT"];
+if (!deploymentName) {
+ console.error("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ process.exit(1);
+}
+const apiKey = process.env["AZURE_OPENAI_API_KEY"];
+if (!apiKey) {
+ console.error("Please set the AZURE_OPENAI_API_KEY environment variable.");
+ process.exit(1);
+}
+
+const openai = new OpenAI({
+ baseURL: endpoint,
+ apiKey: apiKey
+});
+
+async function main() {
+ const completion = await openai.chat.completions.create({
+ messages: [{ role: "developer", content: "You are a helpful assistant." }],
+ model: deploymentName,
+ store: true,
+ });
+
+ console.log(completion.choices[0]);
+}
+
+main();
\ No newline at end of file
diff --git a/generated-snippets/javascript/chat-responses/entra/package.json b/generated-snippets/javascript/chat-responses/entra/package.json
new file mode 100644
index 0000000..a34b31e
--- /dev/null
+++ b/generated-snippets/javascript/chat-responses/entra/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "sample",
+ "version": "1.0.0",
+ "type": "module",
+ "dependencies": {
+ "openai": "5.19.1", "@azure/identity": "4.11.1" }
+}
diff --git a/generated-snippets/javascript/chat-responses/entra/sample.js b/generated-snippets/javascript/chat-responses/entra/sample.js
new file mode 100644
index 0000000..560a5d4
--- /dev/null
+++ b/generated-snippets/javascript/chat-responses/entra/sample.js
@@ -0,0 +1,40 @@
+import OpenAI from "openai";
+import { getBearerTokenProvider, DefaultAzureCredential } from "@azure/identity";
+
+const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
+if (!endpoint) {
+ console.error("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ process.exit(1);
+}
+const deploymentName = process.env["AZURE_OPENAI_DEPLOYMENT"];
+if (!deploymentName) {
+ console.error("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ process.exit(1);
+}
+const tokenProvider = getBearerTokenProvider(
+ new DefaultAzureCredential(),
+ 'https://cognitiveservices.azure.com/.default');
+
+const openai = new OpenAI({
+ baseURL: endpoint,
+ apiKey: tokenProvider
+});
+
+async function main() {
+ const runner = openai.responses
+ .stream({
+ model: deploymentName,
+ input: 'solve 8x + 31 = 2',
+ })
+ .on('event', (event) => console.log(event))
+ .on('response.output_text.delta', (diff) => process.stdout.write(diff.delta));
+
+ for await (const event of runner) {
+ console.log('event', event);
+ }
+
+ const result = await runner.finalResponse();
+ console.log(result);
+}
+
+main();
diff --git a/generated-snippets/javascript/chat-responses/keyAuth/package.json b/generated-snippets/javascript/chat-responses/keyAuth/package.json
new file mode 100644
index 0000000..a34b31e
--- /dev/null
+++ b/generated-snippets/javascript/chat-responses/keyAuth/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "sample",
+ "version": "1.0.0",
+ "type": "module",
+ "dependencies": {
+ "openai": "5.19.1", "@azure/identity": "4.11.1" }
+}
diff --git a/generated-snippets/javascript/chat-responses/keyAuth/sample.js b/generated-snippets/javascript/chat-responses/keyAuth/sample.js
new file mode 100644
index 0000000..b2b2dac
--- /dev/null
+++ b/generated-snippets/javascript/chat-responses/keyAuth/sample.js
@@ -0,0 +1,41 @@
+import OpenAI from "openai";
+
+const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
+if (!endpoint) {
+ console.error("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ process.exit(1);
+}
+const deploymentName = process.env["AZURE_OPENAI_DEPLOYMENT"];
+if (!deploymentName) {
+ console.error("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ process.exit(1);
+}
+const apiKey = process.env["AZURE_OPENAI_API_KEY"];
+if (!apiKey) {
+ console.error("Please set the AZURE_OPENAI_API_KEY environment variable.");
+ process.exit(1);
+}
+
+const openai = new OpenAI({
+ baseURL: endpoint,
+ apiKey: apiKey
+});
+
+async function main() {
+ const runner = openai.responses
+ .stream({
+ model: deploymentName,
+ input: 'solve 8x + 31 = 2',
+ })
+ .on('event', (event) => console.log(event))
+ .on('response.output_text.delta', (diff) => process.stdout.write(diff.delta));
+
+ for await (const event of runner) {
+ console.log('event', event);
+ }
+
+ const result = await runner.finalResponse();
+ console.log(result);
+}
+
+main();
diff --git a/generated-snippets/javascript/images/entra/package.json b/generated-snippets/javascript/images/entra/package.json
new file mode 100644
index 0000000..a34b31e
--- /dev/null
+++ b/generated-snippets/javascript/images/entra/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "sample",
+ "version": "1.0.0",
+ "type": "module",
+ "dependencies": {
+ "openai": "5.19.1", "@azure/identity": "4.11.1" }
+}
diff --git a/generated-snippets/javascript/images/entra/sample.js b/generated-snippets/javascript/images/entra/sample.js
new file mode 100644
index 0000000..95f8426
--- /dev/null
+++ b/generated-snippets/javascript/images/entra/sample.js
@@ -0,0 +1,34 @@
+import OpenAI from "openai";
+import { getBearerTokenProvider, DefaultAzureCredential } from "@azure/identity";
+import fs from "fs";
+
+const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
+if (!endpoint) {
+ console.error("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ process.exit(1);
+}
+const deploymentName = process.env["AZURE_OPENAI_DEPLOYMENT"];
+if (!deploymentName) {
+ console.error("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ process.exit(1);
+}
+const tokenProvider = getBearerTokenProvider(
+ new DefaultAzureCredential(),
+ 'https://cognitiveservices.azure.com/.default');
+
+const openai = new OpenAI({
+ baseURL: endpoint,
+ apiKey: tokenProvider
+});
+
+const prompt = "A cute baby polar bear.";
+
+const result = await openai.images.generate({
+ model: deploymentName,
+ prompt,
+});
+
+// Save the image to a file
+const image_base64 = result.data[0].b64_json;
+const image_bytes = Buffer.from(image_base64, "base64");
+fs.writeFileSync("output.png", image_bytes);
\ No newline at end of file
diff --git a/generated-snippets/javascript/images/keyAuth/package.json b/generated-snippets/javascript/images/keyAuth/package.json
new file mode 100644
index 0000000..a34b31e
--- /dev/null
+++ b/generated-snippets/javascript/images/keyAuth/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "sample",
+ "version": "1.0.0",
+ "type": "module",
+ "dependencies": {
+ "openai": "5.19.1", "@azure/identity": "4.11.1" }
+}
diff --git a/generated-snippets/javascript/images/keyAuth/sample.js b/generated-snippets/javascript/images/keyAuth/sample.js
new file mode 100644
index 0000000..0530f77
--- /dev/null
+++ b/generated-snippets/javascript/images/keyAuth/sample.js
@@ -0,0 +1,35 @@
+import OpenAI from "openai";
+import fs from "fs";
+
+const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
+if (!endpoint) {
+ console.error("Please set the AZURE_OPENAI_ENDPOINT environment variable.");
+ process.exit(1);
+}
+const deploymentName = process.env["AZURE_OPENAI_DEPLOYMENT"];
+if (!deploymentName) {
+ console.error("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.");
+ process.exit(1);
+}
+const apiKey = process.env["AZURE_OPENAI_API_KEY"];
+if (!apiKey) {
+ console.error("Please set the AZURE_OPENAI_API_KEY environment variable.");
+ process.exit(1);
+}
+
+const openai = new OpenAI({
+ baseURL: endpoint,
+ apiKey: apiKey
+});
+
+const prompt = "A cute baby polar bear.";
+
+const result = await openai.images.generate({
+ model: deploymentName,
+ prompt,
+});
+
+// Save the image to a file
+const image_base64 = result.data[0].b64_json;
+const image_bytes = Buffer.from(image_base64, "base64");
+fs.writeFileSync("output.png", image_bytes);
\ No newline at end of file
diff --git a/generated-snippets/python/chat-completion/entra/requirements.txt b/generated-snippets/python/chat-completion/entra/requirements.txt
new file mode 100644
index 0000000..3d23310
--- /dev/null
+++ b/generated-snippets/python/chat-completion/entra/requirements.txt
@@ -0,0 +1,2 @@
+openai==1.109.1
+azure-identity==1.24.0
diff --git a/generated-snippets/python/chat-completion/entra/sample.py b/generated-snippets/python/chat-completion/entra/sample.py
new file mode 100644
index 0000000..dce0be3
--- /dev/null
+++ b/generated-snippets/python/chat-completion/entra/sample.py
@@ -0,0 +1,31 @@
+import os
+from openai import OpenAI
+from azure.identity import DefaultAzureCredential, get_bearer_token_provider
+
+endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
+if not endpoint:
+ raise ValueError("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+
+deployment_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT")
+if not deployment_name:
+ raise ValueError("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+
+token_provider = get_bearer_token_provider(DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
+
+client = OpenAI(
+ base_url=endpoint,
+ api_key=token_provider
+)
+
+completion = client.chat.completions.create(
+ model=deployment_name,
+ messages=[
+ {
+ "role": "user",
+ "content": "What is the capital of France?",
+ }
+ ],
+ temperature=0.7,
+)
+
+print(completion.choices[0].message)
\ No newline at end of file
diff --git a/generated-snippets/python/chat-completion/keyAuth/requirements.txt b/generated-snippets/python/chat-completion/keyAuth/requirements.txt
new file mode 100644
index 0000000..3d23310
--- /dev/null
+++ b/generated-snippets/python/chat-completion/keyAuth/requirements.txt
@@ -0,0 +1,2 @@
+openai==1.109.1
+azure-identity==1.24.0
diff --git a/generated-snippets/python/chat-completion/keyAuth/sample.py b/generated-snippets/python/chat-completion/keyAuth/sample.py
new file mode 100644
index 0000000..b2931e3
--- /dev/null
+++ b/generated-snippets/python/chat-completion/keyAuth/sample.py
@@ -0,0 +1,33 @@
+import os
+from openai import OpenAI
+
+endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
+if not endpoint:
+ raise ValueError("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+
+deployment_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT")
+if not deployment_name:
+ raise ValueError("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+
+api_key = os.environ.get("AZURE_OPENAI_API_KEY")
+if not api_key:
+ raise ValueError("Please set the AZURE_OPENAI_API_KEY environment variable.")
+
+
+client = OpenAI(
+ base_url=endpoint,
+ api_key=api_key
+)
+
+completion = client.chat.completions.create(
+ model=deployment_name,
+ messages=[
+ {
+ "role": "user",
+ "content": "What is the capital of France?",
+ }
+ ],
+ temperature=0.7,
+)
+
+print(completion.choices[0].message)
\ No newline at end of file
diff --git a/generated-snippets/python/chat-responses/entra/requirements.txt b/generated-snippets/python/chat-responses/entra/requirements.txt
new file mode 100644
index 0000000..3d23310
--- /dev/null
+++ b/generated-snippets/python/chat-responses/entra/requirements.txt
@@ -0,0 +1,2 @@
+openai==1.109.1
+azure-identity==1.24.0
diff --git a/generated-snippets/python/chat-responses/entra/sample.py b/generated-snippets/python/chat-responses/entra/sample.py
new file mode 100644
index 0000000..7516df1
--- /dev/null
+++ b/generated-snippets/python/chat-responses/entra/sample.py
@@ -0,0 +1,25 @@
+import os
+from openai import OpenAI
+from azure.identity import DefaultAzureCredential, get_bearer_token_provider
+
+endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
+if not endpoint:
+ raise ValueError("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+
+deployment_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT")
+if not deployment_name:
+ raise ValueError("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+
+token_provider = get_bearer_token_provider(DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
+
+client = OpenAI(
+ base_url=endpoint,
+ api_key=token_provider
+)
+
+response = client.responses.create(
+ model=deployment_name,
+ input="What is the capital of France?",
+)
+
+print(f"answer: {response.output[0]}")
diff --git a/generated-snippets/python/chat-responses/keyAuth/requirements.txt b/generated-snippets/python/chat-responses/keyAuth/requirements.txt
new file mode 100644
index 0000000..3d23310
--- /dev/null
+++ b/generated-snippets/python/chat-responses/keyAuth/requirements.txt
@@ -0,0 +1,2 @@
+openai==1.109.1
+azure-identity==1.24.0
diff --git a/generated-snippets/python/chat-responses/keyAuth/sample.py b/generated-snippets/python/chat-responses/keyAuth/sample.py
new file mode 100644
index 0000000..8cb8fbf
--- /dev/null
+++ b/generated-snippets/python/chat-responses/keyAuth/sample.py
@@ -0,0 +1,27 @@
+import os
+from openai import OpenAI
+
+endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
+if not endpoint:
+ raise ValueError("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+
+deployment_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT")
+if not deployment_name:
+ raise ValueError("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+
+api_key = os.environ.get("AZURE_OPENAI_API_KEY")
+if not api_key:
+ raise ValueError("Please set the AZURE_OPENAI_API_KEY environment variable.")
+
+
+client = OpenAI(
+ base_url=endpoint,
+ api_key=api_key
+)
+
+response = client.responses.create(
+ model=deployment_name,
+ input="What is the capital of France?",
+)
+
+print(f"answer: {response.output[0]}")
diff --git a/generated-snippets/python/images/entra/requirements.txt b/generated-snippets/python/images/entra/requirements.txt
new file mode 100644
index 0000000..3d23310
--- /dev/null
+++ b/generated-snippets/python/images/entra/requirements.txt
@@ -0,0 +1,2 @@
+openai==1.109.1
+azure-identity==1.24.0
diff --git a/generated-snippets/python/images/entra/sample.py b/generated-snippets/python/images/entra/sample.py
new file mode 100644
index 0000000..34d5643
--- /dev/null
+++ b/generated-snippets/python/images/entra/sample.py
@@ -0,0 +1,30 @@
+import base64
+import os
+from openai import OpenAI
+from azure.identity import DefaultAzureCredential, get_bearer_token_provider
+
+endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
+if not endpoint:
+ raise ValueError("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+
+deployment_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT")
+if not deployment_name:
+ raise ValueError("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+
+token_provider = get_bearer_token_provider(DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
+
+client = OpenAI(
+ base_url=endpoint,
+ api_key=token_provider
+)
+
+img = client.images.generate(
+ model=deployment_name,
+ prompt="A cute baby polar bear",
+ n=1,
+ size="1024x1024",
+)
+
+image_bytes = base64.b64decode(img.data[0].b64_json)
+with open("output.png", "wb") as f:
+ f.write(image_bytes)
diff --git a/generated-snippets/python/images/keyAuth/requirements.txt b/generated-snippets/python/images/keyAuth/requirements.txt
new file mode 100644
index 0000000..3d23310
--- /dev/null
+++ b/generated-snippets/python/images/keyAuth/requirements.txt
@@ -0,0 +1,2 @@
+openai==1.109.1
+azure-identity==1.24.0
diff --git a/generated-snippets/python/images/keyAuth/sample.py b/generated-snippets/python/images/keyAuth/sample.py
new file mode 100644
index 0000000..28f152b
--- /dev/null
+++ b/generated-snippets/python/images/keyAuth/sample.py
@@ -0,0 +1,32 @@
+import base64
+import os
+from openai import OpenAI
+
+endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
+if not endpoint:
+ raise ValueError("Please set the AZURE_OPENAI_ENDPOINT environment variable.")
+
+deployment_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT")
+if not deployment_name:
+ raise ValueError("Please set the AZURE_OPENAI_DEPLOYMENT environment variable.")
+
+api_key = os.environ.get("AZURE_OPENAI_API_KEY")
+if not api_key:
+ raise ValueError("Please set the AZURE_OPENAI_API_KEY environment variable.")
+
+
+client = OpenAI(
+ base_url=endpoint,
+ api_key=api_key
+)
+
+img = client.images.generate(
+ model=deployment_name,
+ prompt="A cute baby polar bear",
+ n=1,
+ size="1024x1024",
+)
+
+image_bytes = base64.b64decode(img.data[0].b64_json)
+with open("output.png", "wb") as f:
+ f.write(image_bytes)