Crestapps core azure openai

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core azure openai is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for using Azure OpenAI and Azure AI Speech in CrestApps.Core 2.0. Covers AddAzureOpenAI and AddCoreAIAzureOpenAI registration, Azure connections with Endpoint, AuthenticationType (Default, ApiKey, ManagedIdentity), IdentityId and the ChatApi setting, the CrestApps AI AzureClient retry and logg

How to use this skill

Skill file

CrestApps.Core Azure OpenAI

The CrestApps.Core.AI.OpenAI.Azure package connects CrestApps.Core to Azure OpenAI (client name "Azure") and to Azure AI Speech (client name "AzureSpeech"). Use it for enterprise workloads that need regional data residency, managed identity, or private networking.

Guidelines

Registration

using CrestApps.Core.AI.OpenAI.Azure;

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddAzureOpenAI()
    )
);

Without the suite builder, register the core and orchestration services too; AddCoreAIAzureOpenAI() alone adds only the provider:

builder.Services
    .AddCoreAIServices()
    .AddCoreAIOrchestration()
    .AddCoreAIAzureOpenAI();

AddCoreAIAzureOpenAI() registers AzureOpenAIClientProvider (chat, embeddings, images, speech-to-text, realtime), AzureSpeechClientProvider (Azure AI Speech speech-to-text and text-to-speech), AzureOpenAIConnectionHandler, the AzureOpenAICompletionClient completion client for "Azure", AzureClientOptions bound from CrestApps:AI:AzureClient, and two deployment providers: "Azure" and the contained-connection "AzureSpeech".

Connection

{
  "CrestApps": {
    "AI": {
      "Connections": [
        {
          "Name": "azure-production",
          "ClientName": "Azure",
          "Endpoint": "https://my-resource.openai.azure.com/",
          "AuthenticationType": "ApiKey",
          "ApiKey": "your-api-key"
        },
        {
          "Name": "azure-managed",
          "ClientName": "Azure",
          "Endpoint": "https://my-resource.openai.azure.com/",
          "AuthenticationType": "ManagedIdentity",
          "IdentityId": "user-assigned-client-id"
        }
      ]
    }
  }
}

| AuthenticationType | Credential used |

|---|---|

| Default or empty | DefaultAzureCredential (environment, workload identity, managed identity, Azure CLI, Visual Studio) |

| ApiKey | ApiKeyCredential(ApiKey) |

| ManagedIdentity | ManagedIdentityCredential, system-assigned when IdentityId is empty, otherwise the user-assigned client ID |

For managed identity, grant the hosting identity the Cognitive Services OpenAI User role on the resource. "AzureOpenAI" is accepted as an alias of the "Azure" client name.

Shared Azure SDK options

CrestApps:AI:AzureClient binds AzureClientOptions for every Azure OpenAI connection:

{
  "CrestApps": {
    "AI": {
      "AzureClient": {
        "EnableDefaultRetryPolicy": true,
        "MaxRetryAttempts": 5,
        "RateLimitRetryDelay": "00:00:01",
        "BackoffType": "Exponential",
        "UseJitter": true,
        "MaxRetryDelay": "00:00:32",
        "EnableLogging": false,
        "EnableMessageLogging": false,
        "EnableMessageContentLogging": false
      }
    }
  }
}

Deployments

{
  "CrestApps": {
    "AI": {
      "Deployments": [
        {
          "ClientName": "Azure",
          "ConnectionName": "azure-production",
          "Name": "gpt-4o",
          "ModelName": "my-gpt-4o-deployment",
          "Features": [ "textGeneration", "toolCalling", "streaming", "imageInput" ]
        },
        {
          "ClientName": "Azure",
          "ConnectionName": "azure-production",
          "Name": "gpt-5-reasoning",
          "ModelName": "gpt-5",
          "Features": [ "textGeneration", "toolCalling", "streaming", "reasoning" ],
          "Parameters": {
            "reasoningEffort": { "DefaultValue": "None" }
          }
        },
        {
          "ClientName": "Azure",
          "ConnectionName": "azure-production",
          "Name": "text-embedding-3-large",
          "Features": [ "textEmbedding" ]
        },
        {
          "ClientName": "Azure",
          "ConnectionName": "azure-production",
          "Name": "gpt-4o-transcribe",
          "Features": [ "speechToText" ]
        },
        {
          "ClientName": "Azure",
          "ConnectionName": "azure-production",
          "Name": "gpt-realtime",
          "Features": [ "realtime" ]
        },
        {
          "ClientName": "AzureSpeech",
          "Name": "azure-tts",
          "Endpoint": "https://eastus.tts.speech.microsoft.com",
          "AuthenticationType": "ApiKey",
          "ApiKey": "your-speech-key",
          "Features": [ "textToSpeech" ]
        },
        {
          "ClientName": "AzureSpeech",
          "Name": "azure-stt",
          "Endpoint": "https://eastus.stt.speech.microsoft.com",
          "AuthenticationType": "ApiKey",
          "ApiKey": "your-speech-key",
          "Features": [ "speechToText" ]
        }
      ]
    }
  }
}

Fill slot defaults with DefaultAIDeploymentSettings (DefaultChatDeploymentName, DefaultUtilityDeploymentName, DefaultEmbeddingDeploymentName, DefaultImageDeploymentName, DefaultVisionDeploymentName, DefaultSpeechToTextDeploymentName, DefaultTextToSpeechDeploymentName, DefaultRealtimeDeploymentName) and resolve them:

using CrestApps.Core.AI.Clients;
using CrestApps.Core.AI.Deployments;
using CrestApps.Core.AI.Models;
using Microsoft.Extensions.AI;

namespace MyApp.Services;

#pragma warning disable MEAI001 // Microsoft.Extensions.AI speech APIs are evaluation-only.
public sealed class SpeechSynthesisService
{
    private readonly IAIDeploymentManager _deploymentManager;
    private readonly IAIClientFactory _clientFactory;

    public SpeechSynthesisService(IAIDeploymentManager deploymentManager, IAIClientFactory clientFactory)
    {
        _deploymentManager = deploymentManager;
        _clientFactory = clientFactory;
    }

    public async Task<TextToSpeechResponse> SpeakAsync(string text, string voice, CancellationToken cancellationToken = default)
    {
        var deployment = await _deploymentManager.ResolveSlotOrThrowAsync(AIDeploymentSlotNames.TextToSpeech);
        var client = await _clientFactory.CreateTextToSpeechClientAsync(deployment);

        return await client.GetAudioAsync(
            text,
            new TextToSpeechOptions
            {
                VoiceId = voice,
                AudioFormat = "Pcm24000",
                Speed = 1.1f,
            },
            cancellationToken);
    }
}
#pragma warning restore MEAI001

Azure AI Speech Formats and Speed

AzureSpeechServiceTextToSpeechClient honors TextToSpeechOptions.AudioFormat and reports the matching media type. Names are case-insensitive: Pcm8000, Pcm16000, Pcm24000, Pcm48000 (raw PCM, audio/L16), Riff8000 through Riff48000 (WAV), Mp3, Mp3_16000, Mp3_24000, Mp3_48000, or a Speech SDK format name. MP3 at 16 kHz is the default. Raw PCM is what lets Azure Speech be the speaking leg of a cascaded realtime deployment. TextToSpeechOptions.Speed is applied as SSML prosody rate within 0.5 to 2 when a voice is named. Azure Speech has no realtime client, so it cannot be a cascade's speech-to-text leg.

The AzureSpeech text-to-speech client is wrapped in SpeechMarkupTextToSpeechClient, so neutral speech markup (<break time="500ms"/>, <spell>AB12</spell>) is rendered as plain punctuation and spaced letters instead of being read aloud (see crestapps-core-speech-voices). The "Azure" (Azure OpenAI) provider has no text-to-speech client; use AzureSpeech, OpenAI, ElevenLabs or Cartesia for the speaking leg.

Responses API and Realtime

Troubleshooting

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.