MeshWeaver.AI.AzureOpenAI
3.0.0-preview1
dotnet add package MeshWeaver.AI.AzureOpenAI --version 3.0.0-preview1
NuGet\Install-Package MeshWeaver.AI.AzureOpenAI -Version 3.0.0-preview1
<PackageReference Include="MeshWeaver.AI.AzureOpenAI" Version="3.0.0-preview1" />
<PackageVersion Include="MeshWeaver.AI.AzureOpenAI" Version="3.0.0-preview1" />
<PackageReference Include="MeshWeaver.AI.AzureOpenAI" />
paket add MeshWeaver.AI.AzureOpenAI --version 3.0.0-preview1
#r "nuget: MeshWeaver.AI.AzureOpenAI, 3.0.0-preview1"
#:package MeshWeaver.AI.AzureOpenAI@3.0.0-preview1
#addin nuget:?package=MeshWeaver.AI.AzureOpenAI&version=3.0.0-preview1&prerelease
#tool nuget:?package=MeshWeaver.AI.AzureOpenAI&version=3.0.0-preview1&prerelease
MeshWeaver.AI.AzureOpenAI
Overview
MeshWeaver.AI.AzureOpenAI provides Azure OpenAI integration for the MeshWeaver AI framework, enabling AI-powered agent chats using Azure OpenAI's ChatCompletionAgent. This library is designed for stateless chat completion scenarios without persistent assistant storage.
Features
- Azure OpenAI Integration: Direct integration with Azure OpenAI services
- ChatCompletionAgent Support: Uses Microsoft Semantic Kernel's ChatCompletionAgent for stateless operations
- Factory Pattern: Implements the factory pattern for creating and managing agent chats
- Configuration-Based Setup: Uses
AIConfigurationfor secure credential management - Extensible Architecture: Built on top of MeshWeaver.AI's
ChatCompletionAgentChatFactorybase class
Installation
This package is part of the MeshWeaver solution and should be referenced as a project dependency:
<ProjectReference Include="..\MeshWeaver.AI.AzureOpenAI\MeshWeaver.AI.AzureOpenAI.csproj" />
Configuration
1. Configure AI Credentials
Add the following configuration to your appsettings.json:
{
"AI": {
"Url": "https://your-azure-openai-endpoint.openai.azure.com/",
"ApiKey": "your-api-key-here",
"Models": ["gpt-4", "gpt-35-turbo"]
}
}
2. Register Services
In your Program.cs or service configuration:
using MeshWeaver.AI.AzureOpenAI;
// Configure AI credentials
builder.Services.Configure<AIConfiguration>(
builder.Configuration.GetSection("AI"));
// Add Azure OpenAI services
builder.Services.AddAzureOpenAI();
Usage
Basic Implementation
public class MyService
{
private readonly IAgentChatFactory _chatFactory;
public MyService(IAgentChatFactory chatFactory)
{
_chatFactory = chatFactory;
}
public async Task<IAgentChat> CreateChatAsync()
{
var agentChat = await _chatFactory.CreateAsync();
return agentChat;
}
}
Agent Definition
Create custom agents by implementing IAgentDefinition:
public class MyCustomAgent : IAgentDefinition
{
public string Name => "MyAgent";
public string Description => "A custom AI agent for specific tasks";
public string Instructions => "You are a helpful assistant specialized in...";
}
Architecture
Class Hierarchy
ChatCompletionAgentChatFactory (MeshWeaver.AI)
└── AzureOpenAIChatCompletionAgentChatFactory (MeshWeaver.AI.AzureOpenAI)
Key Components
- AzureOpenAIChatCompletionAgentChatFactory: Main factory class for creating Azure OpenAI-powered agent chats
- AzureOpenAIExtensions: Extension methods for service registration
- AIConfiguration: Configuration model for Azure OpenAI credentials
Security Considerations
- API Key Management: Store API keys securely using Azure Key Vault or similar secure storage
- Environment Variables: Consider using environment variables for sensitive configuration
- Network Security: Ensure secure communication with Azure OpenAI endpoints
Dependencies
- Microsoft.SemanticKernel
- Microsoft.Extensions.Options
- Microsoft.Extensions.DependencyInjection.Abstractions
- MeshWeaver.AI
- MeshWeaver.Messaging.Hub
Troubleshooting
Common Issues
- Missing API Key: Ensure
AIConfiguration.ApiKeyis properly configured - Invalid Endpoint: Verify the
AIConfiguration.Urlformat - Model Not Available: Check that the specified models exist in your Azure OpenAI deployment
Logging
Enable detailed logging to troubleshoot issues:
builder.Services.AddLogging(logging =>
{
logging.AddConsole();
logging.SetMinimumLevel(LogLevel.Debug);
});
Related Projects
- MeshWeaver.AI - Core AI services and abstractions
- MeshWeaver.AI.AzureFoundry - Azure AI Foundry integration
- MeshWeaver.Blazor.Chat - Chat UI components
Contributing
This project is part of the MeshWeaver ecosystem. Please follow the established patterns and conventions when contributing.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Azure.AI.OpenAI (>= 2.9.0-beta.1)
- MeshWeaver.AI (>= 3.0.0-preview1)
- MeshWeaver.Messaging.Hub (>= 3.0.0-preview1)
- Microsoft.Agents.AI.OpenAI (>= 1.1.0)
- Microsoft.Extensions.AI.OpenAI (>= 10.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.6)
- Microsoft.Extensions.Options (>= 10.0.6)
- OpenAI (>= 2.10.0)
- System.Security.Cryptography.Xml (>= 10.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-preview1 | 87 | 4/16/2026 |
| 2.5.0 | 183 | 11/3/2025 |
| 2.4.0 | 172 | 10/2/2025 |
| 2.3.0 | 259 | 8/4/2025 |
| 2.2.0 | 538 | 7/21/2025 |