[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CS0823KFCXPH1NWZ73W47C":3,"skill-same:01M6CS0823KFCXPH1NWZ73W47C":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":52,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":54,"updatedAt":55,"install":56,"resources":69},"01M6CS0823KFCXPH1NWZ73W47C","azure-ai-openai-dotnet",null,"Azure OpenAI SDK for .NET. Client library for Azure OpenAI and OpenAI services. Use for chat completions, embeddings, image generation, audio transcription, and assistants.","Sam-06060\u002Fjarvis-assistant","Sam-06060","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F208600848?v=4","01M6CRKT7C7FXD21V6HXF293S0","Samson Frank Ganta","01M6CRKTBEKYFD8YX5Z1GT99EE",6,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fmodules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fazure-ai-openai-dotnet\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"dotnet","azure ai","azure","azure ai openai dotnet","openai","embeddings","chat","transcription","community","use","Audio","Image Generation","services","library","image","azure openai","sdk","2026-11-10 10:12:30",false,"---\nname: azure-ai-openai-dotnet\ndescription: Azure OpenAI SDK for .NET. Client library for Azure OpenAI and OpenAI services. Use for chat completions, embeddings, image generation, audio transcription, and assistants.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure.AI.OpenAI (.NET)\n\nClient library for Azure OpenAI Service providing access to OpenAI models including GPT-4, GPT-4o, embeddings, DALL-E, and Whisper.\n\n## Installation\n\n```bash\ndotnet add package Azure.AI.OpenAI\n\n# For OpenAI (non-Azure) compatibility\ndotnet add package OpenAI\n```\n\n**Current Version**: 2.1.0 (stable)\n\n## Environment Variables\n\n```bash\nAZURE_OPENAI_ENDPOINT=https:\u002F\u002F\u003Cresource-name>.openai.azure.com\nAZURE_OPENAI_API_KEY=\u003Capi-key>                    # For key-based auth\nAZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini          # Your deployment name\n```\n\n## Client Hierarchy\n\n```\nAzureOpenAIClient (top-level)\n├── GetChatClient(deploymentName)      → ChatClient\n├── GetEmbeddingClient(deploymentName) → EmbeddingClient\n├── GetImageClient(deploymentName)     → ImageClient\n├── GetAudioClient(deploymentName)     → AudioClient\n└── GetAssistantClient()               → AssistantClient\n```\n\n## Authentication\n\n### API Key Authentication\n\n```csharp\nusing Azure;\nusing Azure.AI.OpenAI;\n\nAzureOpenAIClient client = new(\n    new Uri(Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\")!),\n    new AzureKeyCredential(Environment.GetEnvironmentVariable(\"AZURE_OPENAI_API_KEY\")!));\n```\n\n### Microsoft Entra ID (Recommended for Production)\n\n```csharp\nusing Azure.Identity;\nusing Azure.AI.OpenAI;\n\nAzureOpenAIClient client = new(\n    new Uri(Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\")!),\n    new DefaultAzureCredential());\n```\n\n### Using OpenAI SDK Directly with Azure\n\n```csharp\nusing Azure.Identity;\nusing OpenAI;\nusing OpenAI.Chat;\nusing System.ClientModel.Primitives;\n\n#pragma warning disable OPENAI001\n\nBearerTokenPolicy tokenPolicy = new(\n    new DefaultAzureCredential(),\n    \"https:\u002F\u002Fcognitiveservices.azure.com\u002F.default\");\n\nChatClient client = new(\n    model: \"gpt-4o-mini\",\n    authenticationPolicy: tokenPolicy,\n    options: new OpenAIClientOptions()\n    {\n        Endpoint = new Uri(\"https:\u002F\u002FYOUR-RESOURCE.openai.azure.com\u002Fopenai\u002Fv1\")\n    });\n```\n\n## Chat Completions\n\n### Basic Chat\n\n```csharp\nusing Azure.AI.OpenAI;\nusing OpenAI.Chat;\n\nAzureOpenAIClient azureClient = new(\n    new Uri(endpoint),\n    new DefaultAzureCredential());\n\nChatClient chatClient = azureClient.GetChatClient(\"gpt-4o-mini\");\n\nChatCompletion completion = chatClient.CompleteChat(\n[\n    new SystemChatMessage(\"You are a helpful assistant.\"),\n    new UserChatMessage(\"What is Azure OpenAI?\")\n]);\n\nConsole.WriteLine(completion.Content[0].Text);\n```\n\n### Async Chat\n\n```csharp\nChatCompletion completion = await chatClient.CompleteChatAsync(\n[\n    new SystemChatMessage(\"You are a helpful assistant.\"),\n    new UserChatMessage(\"Explain cloud computing in simple terms.\")\n]);\n\nConsole.WriteLine($\"Response: {completion.Content[0].Text}\");\nConsole.WriteLine($\"Tokens used: {completion.Usage.TotalTokenCount}\");\n```\n\n### Streaming Chat\n\n```csharp\nawait foreach (StreamingChatCompletionUpdate update \n    in chatClient.CompleteChatStreamingAsync(messages))\n{\n    if (update.ContentUpdate.Count > 0)\n    {\n        Console.Write(update.ContentUpdate[0].Text);\n    }\n}\n```\n\n### Chat with Options\n\n```csharp\nChatCompletionOptions options = new()\n{\n    MaxOutputTokenCount = 1000,\n    Temperature = 0.7f,\n    TopP = 0.95f,\n    FrequencyPenalty = 0,\n    PresencePenalty = 0\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(messages, options);\n```\n\n### Multi-turn Conversation\n\n```csharp\nList\u003CChatMessage> messages = new()\n{\n    new SystemChatMessage(\"You are a helpful assistant.\"),\n    new UserChatMessage(\"Hi, can you help me?\"),\n    new AssistantChatMessage(\"Of course! What do you need help with?\"),\n    new UserChatMessage(\"What's the capital of France?\")\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(messages);\nmessages.Add(new AssistantChatMessage(completion.Content[0].Text));\n```\n\n## Structured Outputs (JSON Schema)\n\n```csharp\nusing System.Text.Json;\n\nChatCompletionOptions options = new()\n{\n    ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(\n        jsonSchemaFormatName: \"math_reasoning\",\n        jsonSchema: BinaryData.FromBytes(\"\"\"\n            {\n                \"type\": \"object\",\n                \"properties\": {\n                    \"steps\": {\n                        \"type\": \"array\",\n                        \"items\": {\n                            \"type\": \"object\",\n                            \"properties\": {\n                                \"explanation\": { \"type\": \"string\" },\n                                \"output\": { \"type\": \"string\" }\n                            },\n                            \"required\": [\"explanation\", \"output\"],\n                            \"additionalProperties\": false\n                        }\n                    },\n                    \"final_answer\": { \"type\": \"string\" }\n                },\n                \"required\": [\"steps\", \"final_answer\"],\n                \"additionalProperties\": false\n            }\n            \"\"\"u8.ToArray()),\n        jsonSchemaIsStrict: true)\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n    [new UserChatMessage(\"How can I solve 8x + 7 = -23?\")],\n    options);\n\nusing JsonDocument json = JsonDocument.Parse(completion.Content[0].Text);\nConsole.WriteLine($\"Answer: {json.RootElement.GetProperty(\"final_answer\")}\");\n```\n\n## Reasoning Models (o1, o4-mini)\n\n```csharp\nChatCompletionOptions options = new()\n{\n    ReasoningEffortLevel = ChatReasoningEffortLevel.Low,\n    MaxOutputTokenCount = 100000\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n[\n    new DeveloperChatMessage(\"You are a helpful assistant\"),\n    new UserChatMessage(\"Explain the theory of relativity\")\n], options);\n```\n\n## Azure AI Search Integration (RAG)\n\n```csharp\nusing Azure.AI.OpenAI.Chat;\n\n#pragma warning disable AOAI001\n\nChatCompletionOptions options = new();\noptions.AddDataSource(new AzureSearchChatDataSource()\n{\n    Endpoint = new Uri(searchEndpoint),\n    IndexName = searchIndex,\n    Authentication = DataSourceAuthentication.FromApiKey(searchKey)\n});\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n    [new UserChatMessage(\"What health plans are available?\")],\n    options);\n\nChatMessageContext context = completion.GetMessageContext();\nif (context?.Intent is not null)\n{\n    Console.WriteLine($\"Intent: {context.Intent}\");\n}\nforeach (ChatCitation citation in context?.Citations ?? [])\n{\n    Console.WriteLine($\"Citation: {citation.Content}\");\n}\n```\n\n## Embeddings\n\n```csharp\nusing OpenAI.Embeddings;\n\nEmbeddingClient embeddingClient = azureClient.GetEmbeddingClient(\"text-embedding-ada-002\");\n\nOpenAIEmbedding embedding = await embeddingClient.GenerateEmbeddingAsync(\"Hello, world!\");\nReadOnlyMemory\u003Cfloat> vector = embedding.ToFloats();\n\nConsole.WriteLine($\"Embedding dimensions: {vector.Length}\");\n```\n\n### Batch Embeddings\n\n```csharp\nList\u003Cstring> inputs = new()\n{\n    \"First document text\",\n    \"Second document text\",\n    \"Third document text\"\n};\n\nOpenAIEmbeddingCollection embeddings = await embeddingClient.GenerateEmbeddingsAsync(inputs);\n\nforeach (OpenAIEmbedding emb in embeddings)\n{\n    Console.WriteLine($\"Index {emb.Index}: {emb.ToFloats().Length} dimensions\");\n}\n```\n\n## Image Generation (DALL-E)\n\n```csharp\nusing OpenAI.Images;\n\nImageClient imageClient = azureClient.GetImageClient(\"dall-e-3\");\n\nGeneratedImage image = await imageClient.GenerateImageAsync(\n    \"A futuristic city skyline at sunset\",\n    new ImageGenerationOptions\n    {\n        Size = GeneratedImageSize.W1024xH1024,\n        Quality = GeneratedImageQuality.High,\n        Style = GeneratedImageStyle.Vivid\n    });\n\nConsole.WriteLine($\"Image URL: {image.ImageUri}\");\n```\n\n## Audio (Whisper)\n\n### Transcription\n\n```csharp\nusing OpenAI.Audio;\n\nAudioClient audioClient = azureClient.GetAudioClient(\"whisper\");\n\nAudioTranscription transcription = await audioClient.TranscribeAudioAsync(\n    \"audio.mp3\",\n    new AudioTranscriptionOptions\n    {\n        ResponseFormat = AudioTranscriptionFormat.Verbose,\n        Language = \"en\"\n    });\n\nConsole.WriteLine(transcription.Text);\n```\n\n### Text-to-Speech\n\n```csharp\nBinaryData speech = await audioClient.GenerateSpeechAsync(\n    \"Hello, welcome to Azure OpenAI!\",\n    GeneratedSpeechVoice.Alloy,\n    new SpeechGenerationOptions\n    {\n        SpeedRatio = 1.0f,\n        ResponseFormat = GeneratedSpeechFormat.Mp3\n    });\n\nawait File.WriteAllBytesAsync(\"output.mp3\", speech.ToArray());\n```\n\n## Function Calling (Tools)\n\n```csharp\nChatTool getCurrentWeatherTool = ChatTool.CreateFunctionTool(\n    functionName: \"get_current_weather\",\n    functionDescription: \"Get the current weather in a given location\",\n    functionParameters: BinaryData.FromString(\"\"\"\n        {\n            \"type\": \"object\",\n            \"properties\": {\n                \"location\": {\n                    \"type\": \"string\",\n                    \"description\": \"The city and state, e.g. San Francisco, CA\"\n                },\n                \"unit\": {\n                    \"type\": \"string\",\n                    \"enum\": [\"celsius\", \"fahrenheit\"]\n                }\n            },\n            \"required\": [\"location\"]\n        }\n        \"\"\"));\n\nChatCompletionOptions options = new()\n{\n    Tools = { getCurrentWeatherTool }\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n    [new UserChatMessage(\"What's the weather in Seattle?\")],\n    options);\n\nif (completion.FinishReason == ChatFinishReason.ToolCalls)\n{\n    foreach (ChatToolCall toolCall in completion.ToolCalls)\n    {\n        Console.WriteLine($\"Function: {toolCall.FunctionName}\");\n        Console.WriteLine($\"Arguments: {toolCall.FunctionArguments}\");\n    }\n}\n```\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `AzureOpenAIClient` | Top-level client for Azure OpenAI |\n| `ChatClient` | Chat completions |\n| `EmbeddingClient` | Text embeddings |\n| `ImageClient` | Image generation (DALL-E) |\n| `AudioClient` | Audio transcription\u002FTTS |\n| `ChatCompletion` | Chat response |\n| `ChatCompletionOptions` | Request configuration |\n| `StreamingChatCompletionUpdate` | Streaming response chunk |\n| `ChatMessage` | Base message type |\n| `SystemChatMessage` | System prompt |\n| `UserChatMessage` | User input |\n| `AssistantChatMessage` | Assistant response |\n| `DeveloperChatMessage` | Developer message (reasoning models) |\n| `ChatTool` | Function\u002Ftool definition |\n| `ChatToolCall` | Tool invocation request |\n\n## Best Practices\n\n1. **Use Entra ID in production** — Avoid API keys; use `DefaultAzureCredential`\n2. **Reuse client instances** — Create once, share across requests\n3. **Handle rate limits** — Implement exponential backoff for 429 errors\n4. **Stream for long responses** — Use `CompleteChatStreamingAsync` for better UX\n5. **Set appropriate timeouts** — Long completions may need extended timeouts\n6. **Use structured outputs** — JSON schema ensures consistent response format\n7. **Monitor token usage** — Track `completion.Usage` for cost management\n8. **Validate tool calls** — Always validate function arguments before execution\n\n## Error Handling\n\n```csharp\nusing Azure;\n\ntry\n{\n    ChatCompletion completion = await chatClient.CompleteChatAsync(messages);\n}\ncatch (RequestFailedException ex) when (ex.Status == 429)\n{\n    Console.WriteLine(\"Rate limited. Retry after delay.\");\n    await Task.Delay(TimeSpan.FromSeconds(10));\n}\ncatch (RequestFailedException ex) when (ex.Status == 400)\n{\n    Console.WriteLine($\"Bad request: {ex.Message}\");\n}\ncatch (RequestFailedException ex)\n{\n    Console.WriteLine($\"Azure OpenAI error: {ex.Status} - {ex.Message}\");\n}\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Azure.AI.OpenAI` | Azure OpenAI client (this SDK) | `dotnet add package Azure.AI.OpenAI` |\n| `OpenAI` | OpenAI compatibility | `dotnet add package OpenAI` |\n| `Azure.Identity` | Authentication | `dotnet add package Azure.Identity` |\n| `Azure.Search.Documents` | AI Search for RAG | `dotnet add package Azure.Search.Documents` |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FAzure.AI.OpenAI |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fazure.ai.openai |\n| Migration Guide (1.0→2.0) | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002Fhow-to\u002Fdotnet-migration |\n| Quickstart | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002Fquickstart |\n| GitHub Source | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fopenai\u002FAzure.AI.OpenAI |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n","# Azure.AI.OpenAI (.NET)\n\nClient library for Azure OpenAI Service providing access to OpenAI models including GPT-4, GPT-4o, embeddings, DALL-E, and Whisper.\n\n## Installation\n\n```bash\ndotnet add package Azure.AI.OpenAI\n\n# For OpenAI (non-Azure) compatibility\ndotnet add package OpenAI\n```\n\n**Current Version**: 2.1.0 (stable)\n\n## Environment Variables\n\n```bash\nAZURE_OPENAI_ENDPOINT=https:\u002F\u002F\u003Cresource-name>.openai.azure.com\nAZURE_OPENAI_API_KEY=\u003Capi-key>                    # For key-based auth\nAZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini          # Your deployment name\n```\n\n## Client Hierarchy\n\n```\nAzureOpenAIClient (top-level)\n├── GetChatClient(deploymentName)      → ChatClient\n├── GetEmbeddingClient(deploymentName) → EmbeddingClient\n├── GetImageClient(deploymentName)     → ImageClient\n├── GetAudioClient(deploymentName)     → AudioClient\n└── GetAssistantClient()               → AssistantClient\n```\n\n## Authentication\n\n### API Key Authentication\n\n```csharp\nusing Azure;\nusing Azure.AI.OpenAI;\n\nAzureOpenAIClient client = new(\n    new Uri(Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\")!),\n    new AzureKeyCredential(Environment.GetEnvironmentVariable(\"AZURE_OPENAI_API_KEY\")!));\n```\n\n### Microsoft Entra ID (Recommended for Production)\n\n```csharp\nusing Azure.Identity;\nusing Azure.AI.OpenAI;\n\nAzureOpenAIClient client = new(\n    new Uri(Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\")!),\n    new DefaultAzureCredential());\n```\n\n### Using OpenAI SDK Directly with Azure\n\n```csharp\nusing Azure.Identity;\nusing OpenAI;\nusing OpenAI.Chat;\nusing System.ClientModel.Primitives;\n\n#pragma warning disable OPENAI001\n\nBearerTokenPolicy tokenPolicy = new(\n    new DefaultAzureCredential(),\n    \"https:\u002F\u002Fcognitiveservices.azure.com\u002F.default\");\n\nChatClient client = new(\n    model: \"gpt-4o-mini\",\n    authenticationPolicy: tokenPolicy,\n    options: new OpenAIClientOptions()\n    {\n        Endpoint = new Uri(\"https:\u002F\u002FYOUR-RESOURCE.openai.azure.com\u002Fopenai\u002Fv1\")\n    });\n```\n\n## Chat Completions\n\n### Basic Chat\n\n```csharp\nusing Azure.AI.OpenAI;\nusing OpenAI.Chat;\n\nAzureOpenAIClient azureClient = new(\n    new Uri(endpoint),\n    new DefaultAzureCredential());\n\nChatClient chatClient = azureClient.GetChatClient(\"gpt-4o-mini\");\n\nChatCompletion completion = chatClient.CompleteChat(\n[\n    new SystemChatMessage(\"You are a helpful assistant.\"),\n    new UserChatMessage(\"What is Azure OpenAI?\")\n]);\n\nConsole.WriteLine(completion.Content[0].Text);\n```\n\n### Async Chat\n\n```csharp\nChatCompletion completion = await chatClient.CompleteChatAsync(\n[\n    new SystemChatMessage(\"You are a helpful assistant.\"),\n    new UserChatMessage(\"Explain cloud computing in simple terms.\")\n]);\n\nConsole.WriteLine($\"Response: {completion.Content[0].Text}\");\nConsole.WriteLine($\"Tokens used: {completion.Usage.TotalTokenCount}\");\n```\n\n### Streaming Chat\n\n```csharp\nawait foreach (StreamingChatCompletionUpdate update \n    in chatClient.CompleteChatStreamingAsync(messages))\n{\n    if (update.ContentUpdate.Count > 0)\n    {\n        Console.Write(update.ContentUpdate[0].Text);\n    }\n}\n```\n\n### Chat with Options\n\n```csharp\nChatCompletionOptions options = new()\n{\n    MaxOutputTokenCount = 1000,\n    Temperature = 0.7f,\n    TopP = 0.95f,\n    FrequencyPenalty = 0,\n    PresencePenalty = 0\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(messages, options);\n```\n\n### Multi-turn Conversation\n\n```csharp\nList\u003CChatMessage> messages = new()\n{\n    new SystemChatMessage(\"You are a helpful assistant.\"),\n    new UserChatMessage(\"Hi, can you help me?\"),\n    new AssistantChatMessage(\"Of course! What do you need help with?\"),\n    new UserChatMessage(\"What's the capital of France?\")\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(messages);\nmessages.Add(new AssistantChatMessage(completion.Content[0].Text));\n```\n\n## Structured Outputs (JSON Schema)\n\n```csharp\nusing System.Text.Json;\n\nChatCompletionOptions options = new()\n{\n    ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(\n        jsonSchemaFormatName: \"math_reasoning\",\n        jsonSchema: BinaryData.FromBytes(\"\"\"\n            {\n                \"type\": \"object\",\n                \"properties\": {\n                    \"steps\": {\n                        \"type\": \"array\",\n                        \"items\": {\n                            \"type\": \"object\",\n                            \"properties\": {\n                                \"explanation\": { \"type\": \"string\" },\n                                \"output\": { \"type\": \"string\" }\n                            },\n                            \"required\": [\"explanation\", \"output\"],\n                            \"additionalProperties\": false\n                        }\n                    },\n                    \"final_answer\": { \"type\": \"string\" }\n                },\n                \"required\": [\"steps\", \"final_answer\"],\n                \"additionalProperties\": false\n            }\n            \"\"\"u8.ToArray()),\n        jsonSchemaIsStrict: true)\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n    [new UserChatMessage(\"How can I solve 8x + 7 = -23?\")],\n    options);\n\nusing JsonDocument json = JsonDocument.Parse(completion.Content[0].Text);\nConsole.WriteLine($\"Answer: {json.RootElement.GetProperty(\"final_answer\")}\");\n```\n\n## Reasoning Models (o1, o4-mini)\n\n```csharp\nChatCompletionOptions options = new()\n{\n    ReasoningEffortLevel = ChatReasoningEffortLevel.Low,\n    MaxOutputTokenCount = 100000\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n[\n    new DeveloperChatMessage(\"You are a helpful assistant\"),\n    new UserChatMessage(\"Explain the theory of relativity\")\n], options);\n```\n\n## Azure AI Search Integration (RAG)\n\n```csharp\nusing Azure.AI.OpenAI.Chat;\n\n#pragma warning disable AOAI001\n\nChatCompletionOptions options = new();\noptions.AddDataSource(new AzureSearchChatDataSource()\n{\n    Endpoint = new Uri(searchEndpoint),\n    IndexName = searchIndex,\n    Authentication = DataSourceAuthentication.FromApiKey(searchKey)\n});\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n    [new UserChatMessage(\"What health plans are available?\")],\n    options);\n\nChatMessageContext context = completion.GetMessageContext();\nif (context?.Intent is not null)\n{\n    Console.WriteLine($\"Intent: {context.Intent}\");\n}\nforeach (ChatCitation citation in context?.Citations ?? [])\n{\n    Console.WriteLine($\"Citation: {citation.Content}\");\n}\n```\n\n## Embeddings\n\n```csharp\nusing OpenAI.Embeddings;\n\nEmbeddingClient embeddingClient = azureClient.GetEmbeddingClient(\"text-embedding-ada-002\");\n\nOpenAIEmbedding embedding = await embeddingClient.GenerateEmbeddingAsync(\"Hello, world!\");\nReadOnlyMemory\u003Cfloat> vector = embedding.ToFloats();\n\nConsole.WriteLine($\"Embedding dimensions: {vector.Length}\");\n```\n\n### Batch Embeddings\n\n```csharp\nList\u003Cstring> inputs = new()\n{\n    \"First document text\",\n    \"Second document text\",\n    \"Third document text\"\n};\n\nOpenAIEmbeddingCollection embeddings = await embeddingClient.GenerateEmbeddingsAsync(inputs);\n\nforeach (OpenAIEmbedding emb in embeddings)\n{\n    Console.WriteLine($\"Index {emb.Index}: {emb.ToFloats().Length} dimensions\");\n}\n```\n\n## Image Generation (DALL-E)\n\n```csharp\nusing OpenAI.Images;\n\nImageClient imageClient = azureClient.GetImageClient(\"dall-e-3\");\n\nGeneratedImage image = await imageClient.GenerateImageAsync(\n    \"A futuristic city skyline at sunset\",\n    new ImageGenerationOptions\n    {\n        Size = GeneratedImageSize.W1024xH1024,\n        Quality = GeneratedImageQuality.High,\n        Style = GeneratedImageStyle.Vivid\n    });\n\nConsole.WriteLine($\"Image URL: {image.ImageUri}\");\n```\n\n## Audio (Whisper)\n\n### Transcription\n\n```csharp\nusing OpenAI.Audio;\n\nAudioClient audioClient = azureClient.GetAudioClient(\"whisper\");\n\nAudioTranscription transcription = await audioClient.TranscribeAudioAsync(\n    \"audio.mp3\",\n    new AudioTranscriptionOptions\n    {\n        ResponseFormat = AudioTranscriptionFormat.Verbose,\n        Language = \"en\"\n    });\n\nConsole.WriteLine(transcription.Text);\n```\n\n### Text-to-Speech\n\n```csharp\nBinaryData speech = await audioClient.GenerateSpeechAsync(\n    \"Hello, welcome to Azure OpenAI!\",\n    GeneratedSpeechVoice.Alloy,\n    new SpeechGenerationOptions\n    {\n        SpeedRatio = 1.0f,\n        ResponseFormat = GeneratedSpeechFormat.Mp3\n    });\n\nawait File.WriteAllBytesAsync(\"output.mp3\", speech.ToArray());\n```\n\n## Function Calling (Tools)\n\n```csharp\nChatTool getCurrentWeatherTool = ChatTool.CreateFunctionTool(\n    functionName: \"get_current_weather\",\n    functionDescription: \"Get the current weather in a given location\",\n    functionParameters: BinaryData.FromString(\"\"\"\n        {\n            \"type\": \"object\",\n            \"properties\": {\n                \"location\": {\n                    \"type\": \"string\",\n                    \"description\": \"The city and state, e.g. San Francisco, CA\"\n                },\n                \"unit\": {\n                    \"type\": \"string\",\n                    \"enum\": [\"celsius\", \"fahrenheit\"]\n                }\n            },\n            \"required\": [\"location\"]\n        }\n        \"\"\"));\n\nChatCompletionOptions options = new()\n{\n    Tools = { getCurrentWeatherTool }\n};\n\nChatCompletion completion = await chatClient.CompleteChatAsync(\n    [new UserChatMessage(\"What's the weather in Seattle?\")],\n    options);\n\nif (completion.FinishReason == ChatFinishReason.ToolCalls)\n{\n    foreach (ChatToolCall toolCall in completion.ToolCalls)\n    {\n        Console.WriteLine($\"Function: {toolCall.FunctionName}\");\n        Console.WriteLine($\"Arguments: {toolCall.FunctionArguments}\");\n    }\n}\n```\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `AzureOpenAIClient` | Top-level client for Azure OpenAI |\n| `ChatClient` | Chat completions |\n| `EmbeddingClient` | Text embeddings |\n| `ImageClient` | Image generation (DALL-E) |\n| `AudioClient` | Audio transcription\u002FTTS |\n| `ChatCompletion` | Chat response |\n| `ChatCompletionOptions` | Request configuration |\n| `StreamingChatCompletionUpdate` | Streaming response chunk |\n| `ChatMessage` | Base message type |\n| `SystemChatMessage` | System prompt |\n| `UserChatMessage` | User input |\n| `AssistantChatMessage` | Assistant response |\n| `DeveloperChatMessage` | Developer message (reasoning models) |\n| `ChatTool` | Function\u002Ftool definition |\n| `ChatToolCall` | Tool invocation request |\n\n## Best Practices\n\n1. **Use Entra ID in production** — Avoid API keys; use `DefaultAzureCredential`\n2. **Reuse client instances** — Create once, share across requests\n3. **Handle rate limits** — Implement exponential backoff for 429 errors\n4. **Stream for long responses** — Use `CompleteChatStreamingAsync` for better UX\n5. **Set appropriate timeouts** — Long completions may need extended timeouts\n6. **Use structured outputs** — JSON schema ensures consistent response format\n7. **Monitor token usage** — Track `completion.Usage` for cost management\n8. **Validate tool calls** — Always validate function arguments before execution\n\n## Error Handling\n\n```csharp\nusing Azure;\n\ntry\n{\n    ChatCompletion completion = await chatClient.CompleteChatAsync(messages);\n}\ncatch (RequestFailedException ex) when (ex.Status == 429)\n{\n    Console.WriteLine(\"Rate limited. Retry after delay.\");\n    await Task.Delay(TimeSpan.FromSeconds(10));\n}\ncatch (RequestFailedException ex) when (ex.Status == 400)\n{\n    Console.WriteLine($\"Bad request: {ex.Message}\");\n}\ncatch (RequestFailedException ex)\n{\n    Console.WriteLine($\"Azure OpenAI error: {ex.Status} - {ex.Message}\");\n}\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Azure.AI.OpenAI` | Azure OpenAI client (this SDK) | `dotnet add package Azure.AI.OpenAI` |\n| `OpenAI` | OpenAI compatibility | `dotnet add package OpenAI` |\n| `Azure.Identity` | Authentication | `dotnet add package Azure.Identity` |\n| `Azure.Search.Documents` | AI Search for RAG | `dotnet add package Azure.Search.Documents` |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FAzure.AI.OpenAI |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fazure.ai.openai |\n| Migration Guide (1.0→2.0) | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002Fhow-to\u002Fdotnet-migration |\n| Quickstart | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fai-services\u002Fopenai\u002Fquickstart |\n| GitHub Source | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fopenai\u002FAzure.AI.OpenAI |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n",{"name":5,"risk":46,"source":32,"date_added":47,"description":7},"unknown","2026-02-27","main","a50a3aa6b39fb0e1b7db88bef1bfc9c93606e126","modules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fazure-ai-openai-dotnet",0,"https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant","https:\u002F\u002Fgithub.com\u002FSam-06060","Mobile Application Developer | Kotlin | Flutter, KMP, Swfit, Android,Swift UI | Building at Saar It Resources | Creator of Jarvis (AI Assistant)","2026-06-23 05:13:38",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add Sam-06060\u002Fjarvis-assistant --skill azure-ai-openai-dotnet",{"tool":62,"command":63},"bunx","bunx skills add Sam-06060\u002Fjarvis-assistant --skill azure-ai-openai-dotnet",{"tool":65,"command":66},"pnpm","pnpm dlx skills add Sam-06060\u002Fjarvis-assistant --skill azure-ai-openai-dotnet","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fmodules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fazure-ai-openai-dotnet\u002FSKILL.md",true,[],[71,82,98,125,144,171],{"skillNo":72,"name":73,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":79,"publishedAt":41},"01M6GDRVS6FXX3ESH0C9DW01C0","test_skill","https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fscratch\u002Ftest_skill\u002FSKILL.md",[76],{"categoryNo":77,"categoryName":78,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",[80,81],"Test Skill","test",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":41},"01M6GDRQ40HX22MA6XWC31RHHK","zustand-store-ts","Create Zustand stores following established patterns with proper TypeScript types and middleware.","https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fmodules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fzustand-store-ts\u002FSKILL.md",[],[89,90,91,92,93,94,95,32,96,97],"zustand store ts","zustand","store","with","types","middleware","patterns","create","typescript",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":107,"publishedAt":41},"01M6GDRKEA0WE670SPFWX5GKCN","zoom-automation","Automate Zoom meeting creation, management, recordings, webinars, and participant tracking via Rube MCP (Composio). Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fmodules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fzoom-automation\u002FSKILL.md",[104],{"categoryNo":105,"categoryName":106,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[108,109,110,111,112,113,114,115,116,117,118,119,120,121,32,122,123,124],"automation","zoom automation","zoom","first","Tools","search","MCP","via","meeting","automate","critical","creation","webinars","composio","recordings","management","tracking",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":132,"publishedAt":41},"01M6GDRFS1452PC71JQ38S24HR","zoho-crm-automation","Automate Zoho CRM tasks via Rube MCP (Composio): create\u002Fupdate records, search contacts, manage leads, and convert leads. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fmodules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fzoho-crm-automation\u002FSKILL.md",[131],{"categoryNo":105,"categoryName":106,"taxonomyType":21,"taxonomyTypeDesc":22},[133,108,134,135,136,137,138,32,113,139,121,140,118,117,112,141,96,142,114,143],"crm automation","zoho crm","crm","zoho crm automation","zoho","leads","contacts","records","update","tasks","manage",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":153,"publishedAt":41},"01M6GDRCKQBAVTGHX5XBH26KPZ","zod-validation-expert","Expert in Zod — TypeScript-first schema validation. Covers parsing, custom errors, refinements, type inference, and integration with React Hook Form, Next.js, and tRPC.","https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fmodules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fzod-validation-expert\u002FSKILL.md",[150],{"categoryNo":151,"categoryName":152,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[154,155,156,157,158,97,159,160,161,162,163,164,92,165,166,167,168,32,169,170],"expert","zod","zod validation expert","validation","react","safe","parsing","errors","schema validation","react hook form","hook","trpc","form","type","next","schema","Next.js",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":178,"publishedAt":41},"01M6GDR658B08K4MY0RWD4A6EH","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002FSam-06060\u002Fjarvis-assistant\u002Fblob\u002Fmain\u002Fmodules\u002Fagent_skills\u002Fawesome-skills\u002Fplaybooks\u002Fzeroize-audit\u002FSKILL.md",[177],{"categoryNo":105,"categoryName":106,"taxonomyType":21,"taxonomyTypeDesc":22},[179,180,181,182,183,184,185,186,32,187,188,189,190,191,192,193,194,195,196,114],"zeroize audit","audit","write","passwords","get","project","c++","activate","assembly","read","Bash","secrets","analysis","data","flow","verification","code","rust"]