Crestapps core azure ai inference

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core azure ai inference is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for using Azure AI Inference, Azure AI Foundry serverless models, and GitHub Models in CrestApps.Core 2.0. Covers AddAzureAIInference and AddCoreAIAzureAIInference registration, connections with the AzureAIInference client name, Endpoint, AuthenticationType (Default, ApiKey, ManagedIdentity) a

How to use this skill

Skill file

CrestApps.Core Azure AI Inference

The CrestApps.Core.AI.AzureAIInference package uses the Azure.AI.Inference SDK to reach one endpoint that serves many model families (OpenAI, Meta Llama, Mistral, Cohere, and others). It is the provider for GitHub Models and for serverless model deployments in Azure AI Foundry.

Guidelines

Registration

using CrestApps.Core.AI.AzureAIInference;

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

Without the suite builder, register the core and orchestration services as well; AddCoreAIAzureAIInference() alone adds only the provider:

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

It registers AzureAIInferenceClientProvider, the ProviderAICompletionClient<AzureAIInferenceClientMarker> completion client, a connection source, and a deployment provider for AzureAIInferenceConstants.ClientName ("AzureAIInference").

Configuration

{
  "CrestApps": {
    "AI": {
      "Connections": [
        {
          "Name": "github-models",
          "ClientName": "AzureAIInference",
          "Endpoint": "https://models.inference.ai.azure.com",
          "AuthenticationType": "ApiKey",
          "ApiKey": "ghp_your-token-with-models-read"
        },
        {
          "Name": "foundry",
          "ClientName": "AzureAIInference",
          "Endpoint": "https://your-project.inference.ai.azure.com",
          "AuthenticationType": "ManagedIdentity"
        }
      ],
      "Deployments": [
        {
          "ClientName": "AzureAIInference",
          "ConnectionName": "github-models",
          "Name": "gpt-4o-mini",
          "Features": [ "textGeneration", "toolCalling", "streaming" ]
        },
        {
          "ClientName": "AzureAIInference",
          "ConnectionName": "github-models",
          "Name": "llama-3.3-70b",
          "ModelName": "Llama-3.3-70B-Instruct",
          "Features": [ "textGeneration", "streaming" ]
        },
        {
          "ClientName": "AzureAIInference",
          "ConnectionName": "github-models",
          "Name": "text-embedding-3-small",
          "Features": [ "textEmbedding" ]
        }
      ]
    }
  }
}

| AuthenticationType | Credential |

|---|---|

| Default or empty | DefaultAzureCredential |

| ApiKey | AzureKeyCredential(ApiKey) (GitHub token or Azure key) |

| ManagedIdentity | ManagedIdentityCredential, user-assigned when IdentityId is set |

Resolve Through Slots

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

namespace MyApp.Services;

public sealed class ModelComparisonService
{
    private readonly IAIDeploymentManager _deploymentManager;
    private readonly IAICompletionService _completionService;

    public ModelComparisonService(IAIDeploymentManager deploymentManager, IAICompletionService completionService)
    {
        _deploymentManager = deploymentManager;
        _completionService = completionService;
    }

    public async Task<IReadOnlyDictionary<string, string>> CompareAsync(string prompt, CancellationToken cancellationToken = default)
    {
        var results = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
        var candidates = await _deploymentManager.GetAllBySlotAsync(
            AIDeploymentSlotNames.Chat,
            clientName: "AzureAIInference",
            cancellationToken: cancellationToken);

        foreach (var deployment in candidates)
        {
            var response = await _completionService.CompleteAsync(
                deployment,
                [new ChatMessage(ChatRole.User, prompt)],
                new AICompletionContext { DisableTools = true },
                cancellationToken);

            results[deployment.Name] = response.Text;
        }

        return results;
    }
}

GetAllBySlotAsync(AIDeploymentSlotNames.Chat, ...) returns only deployments that declare textGeneration and are not realtime. Use ResolveSlotAsync(AIDeploymentSlotNames.Chat, deploymentName) to pick one, with fallback to the site default in DefaultAIDeploymentSettings.DefaultChatDeploymentName.

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.