Wires CrestApps.Core 2.0's provider-agnostic AI runtime into ASP.NET Core. Covers AddCoreAIServices/AddAISuite registration, deployment features, slot-based resolution via IAIDeploymentManager, and IAIClientFactory clients.
Ships in crestapps-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The runtime is the provider-agnostic layer every other AI feature builds on. A connection holds credentials and an endpoint, a deployment names a model on a connection and declares what that model can do, and a slot says what the installation uses a deployment for.
AddCrestAppsCore(...).AddAISuite(...) for application composition. Use AddCoreAIServices() only when the host composes raw service registrations itself.IAIClientFactory, IAICompletionService, IAICompletionContextBuilder and IAIDeploymentManager. Never create a provider SDK client in business code.Features. A configured entry with no features and no legacy purpose is skipped at startup with the warning "declares no model capabilities".AIDeploymentSlotNames) and ResolveSlotAsync(...). There is no deployment purpose or type in 2.0.crestapps-core-ai-model-capabilities for registering features, parameters and slots, crestapps-core-ai-usage-metering for usage records, crestapps-core-observability for traces and metrics, and the provider skills (crestapps-core-openai, crestapps-core-azure-openai, crestapps-core-ollama, crestapps-core-azure-ai-inference) for provider-specific settings.using CrestApps.Core.AI;
using CrestApps.Core.AI.OpenAI;
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddOpenAI()
)
);
AddAISuite(...) calls AddCoreServices(), AddCoreAIServices() and AddCoreAIOrchestration(). Without the builder:
builder.Services
.AddCoreAIServices()
.AddCoreAIOrchestration()
.AddCoreAIOpenAI();
AddCoreAIServices() also chains AddCoreAITemplating() and AddCoreAIDeploymentCapabilities() (features, parameters and slots). IAIDeploymentManager is registered by AddCoreAIOrchestration(), so register orchestration whenever code resolves deployments.
{
"CrestApps": {
"AI": {
"Connections": [
{
"Name": "openai",
"ClientName": "OpenAI",
"ApiKey": "sk-..."
}
],
"Deployments": [
{
"ClientName": "OpenAI",
"Name": "gpt-5-chat",
"ModelName": "gpt-5",
"ConnectionName": "openai",
"Features": [ "textGeneration", "toolCalling", "streaming", "reasoning" ],
"Parameters": {
"reasoningEffort": { "AllowedValues": [ "Low", "Medium", "High" ], "DefaultValue": "Medium" }
}
},
{
"ClientName": "OpenAI",
"Name": "embeddings",
"ModelName": "text-embedding-3-large",
"ConnectionName": "openai",
"Features": [ "textEmbedding" ]
}
]
}
}
}
Features and Parameters on the entry are shorthand for Properties:AIDeploymentMetadata:Features and ...:Parameters. Both forms work and merge.IAIDeploymentStore.Slot (AIDeploymentSlotNames) | Required feature | Site default (DefaultAIDeploymentSettings) |
|---|---|---|
Chat | textGeneration (excludes realtime) | DefaultChatDeploymentName |
Utility | textGeneration (excludes realtime), falls back to Chat | DefaultUtilityDeploymentName |
Embedding | textEmbedding | DefaultEmbeddingDeploymentName |
Image | imageOutput | DefaultImageDeploymentName |
Vision | imageInput | DefaultVisionDeploymentName |
SpeechToText | speechToText | DefaultSpeechToTextDeploymentName |
TextToSpeech | textToSpeech | DefaultTextToSpeechDeploymentName |
Realtime | realtime | DefaultRealtimeDeploymentName |
Resolution walks one chain: the explicit name, the slot's site default, the fallback slot's explicit name and default, then the first capable deployment.
using CrestApps.Core.AI.Deployments;
using CrestApps.Core.AI.Models;
// Named deployment if it qualifies, otherwise the site default, otherwise the first capable one.
var chat = await deploymentManager.ResolveSlotAsync(AIDeploymentSlotNames.Chat, deploymentName: "gpt-5-chat");
// Background work: explicit utility, site utility, explicit chat, site chat, then first text-capable.
var utility = await deploymentManager.ResolveUtilityOrDefaultAsync(
utilityDeploymentName: profile.UtilityDeploymentName,
chatDeploymentName: profile.ChatDeploymentName);
// Throws InvalidOperationException when nothing can fill the slot.
var embedding = await deploymentManager.ResolveSlotOrThrowAsync(AIDeploymentSlotNames.Embedding);
// Everything eligible for a picker.
var candidates = await deploymentManager.GetAllBySlotAsync(AIDeploymentSlotNames.Chat);
DefaultAIDeploymentSettings is a plain options class. The framework does not bind it from configuration; configure it from your own section or site settings:
builder.Services.Configure<DefaultAIDeploymentSettings>(settings =>
{
settings.DefaultChatDeploymentName = "gpt-5-chat";
settings.DefaultUtilityDeploymentName = "gpt-5-mini";
settings.DefaultEmbeddingDeploymentName = "embeddings";
});
| Service | Use |
|---|---|
IAIClientFactory | Create IChatClient, IEmbeddingGenerator, IImageGenerator, ISpeechToTextClient, ITextToSpeechClient and IRealtimeClient for a deployment. Every overload except realtime accepts an Action<...Builder> pipeline callback, and the factory owns the final Build(serviceProvider) |
IAICompletionService | CompleteAsync / CompleteStreamingAsync(deployment, messages, context, cancellationToken) without the orchestration loop |
IAICompletionContextBuilder | BuildAsync(resource, configure, cancellationToken) runs the context handlers for a profile, interaction or other resource |
IAIDeploymentManager | Slot resolution and deployment CRUD |
IAIDeploymentCapabilityService | What a deployment's model declares |
IAIProviderConnectionStore / IAIDeploymentStore | Merged configuration and store views |
Every client the factory creates is metered, and every chat client is wrapped in CapabilityEnforcingChatClient, which strips tools, JSON response formats and reasoning options the deployment does not declare. Chat clients stream tool calls and results (FunctionCallContent, FunctionResultContent) through FunctionInvokingChatClient, which the AG-UI chat shows as tool cards; NamedAICompletionClient passes stored tool result messages to the provider and drops results whose calls a past-messages limit cut off. CreateRealtimeClientAsync returns a metering wrapper; use GetService to reach the provider client.
The framework registers a scoped DefaultAIOptions that applies the site's GeneralAIOptions overrides. Two of its options control the Microsoft.Extensions.AI gen_ai.* telemetry; the framework's own CrestApps.Core spans and metrics do not depend on them.
EnableOpenTelemetry (off by default) adds gen_ai.* spans and metrics, under the AICompletionService source, to the OpenAI, Azure AI Inference and Ollama completion clients, the Azure OpenAI Responses path, the Claude orchestrator, and the embedding, image, speech and realtime clients from IAIClientFactory. The Azure OpenAI chat-completions path uses the OpenAI SDK's OpenAI.Experimental.EnableOpenTelemetry switch instead.EnableSensitiveData (off by default) adds prompts, responses and tool arguments to those spans. It applies only while EnableOpenTelemetry is on.A site value applies only with its flag: GeneralAIOptions.OverrideEnableOpenTelemetry or OverrideEnableSensitiveData. See crestapps-core-observability.
using CrestApps.Core.AI.Completions;
using CrestApps.Core.AI.Deployments;
using CrestApps.Core.AI.Models;
using Microsoft.Extensions.AI;
public sealed class QuestionService
{
private readonly IAICompletionService _completionService;
private readonly IAIDeploymentManager _deploymentManager;
public QuestionService(
IAICompletionService completionService,
IAIDeploymentManager deploymentManager)
{
_completionService = completionService;
_deploymentManager = deploymentManager;
}
public async Task<string> AskAsync(string question, CancellationToken cancellationToken = default)
{
var deployment = await _deploymentManager.ResolveSlotAsync(
AIDeploymentSlotNames.Chat,
cancellationToken: cancellationToken)
?? throw new InvalidOperationException("No chat deployment is configured.");
var context = new AICompletionContext
{
ChatDeploymentName = deployment.Name,
SystemMessage = "You are a helpful assistant.",
DisableTools = true,
};
var response = await _completionService.CompleteAsync(
deployment,
[new ChatMessage(ChatRole.User, question)],
context,
cancellationToken);
return response.Text;
}
}
To reuse a profile's prompts, tools, persona and model parameters, build the context from the profile instead: await completionContextBuilder.BuildAsync(profile, cancellationToken: cancellationToken).
var chatClient = await clientFactory.CreateChatClientAsync(deployment, builder => builder
.UseDefaultResilience()
.UseUsageLabels(contextType: "Leads", purpose: "LeadScoring"));
var embeddingDeployment = await deploymentManager.ResolveSlotOrThrowAsync(AIDeploymentSlotNames.Embedding);
var generator = await clientFactory.CreateEmbeddingGeneratorAsync(embeddingDeployment);
When you finish a builder yourself, call Build(serviceProvider), never Build().
The OpenAI, Azure OpenAI (Responses API included), Azure AI Inference, Ollama and Claude SDK clients send their HTTP requests through a named HttpClient from IHttpClientFactory:
| Provider | HttpClient name |
|---|---|
| OpenAI | OpenAIConstants.HttpClientName ("CrestApps.OpenAI") |
| Azure OpenAI | AzureOpenAIConstants.HttpClientName ("CrestApps.AzureOpenAI") |
| Azure AI Inference | AzureAIInferenceConstants.HttpClientName ("CrestApps.AzureAIInference") |
| Ollama | OllamaConstants.HttpClientName ("CrestApps.Ollama") |
| Claude | ClaudeClientService.HttpClientName ("CrestApps.Claude") |
AddCoreAIProviderHttpClient(name) registers them with no HttpClient.Timeout (the SDK applies its own), no redirects (an API key header never follows a redirect) and no cookies; the Claude client also decompresses, and Ollama keeps a default HttpClient. A host chooses the transport by configuring a client of the same name after registering the provider, for example to refuse an endpoint whose host name later resolves to an internal address:
builder.Services
.AddHttpClient(OpenAIConstants.HttpClientName)
.ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
{
AllowAutoRedirect = false,
UseCookies = false,
PooledConnectionLifetime = TimeSpan.FromMinutes(2),
// The host's own check of the address each new connection resolves to.
ConnectCallback = AddressGuard.ConnectAsync,
});
AddressGuard stands for the host's own code. Keep PooledConnectionLifetime set: the SDK clients live as long as the container, and a host name is resolved again only when the pool opens a new connection. Requests are logged under System.Net.Http.HttpClient.<name>.
The OpenAI, Azure OpenAI and Ollama SDK clients are kept in AIProviderClientCache, a singleton each provider registers with TryAddSingleton, so each container (each tenant) builds and disposes its own clients. The key includes a hash of the API key, so a rotated key gets a new client; call Clear() on the cache to release clients built with an old key. The OpenAI and Azure OpenAI realtime clients and the Azure Speech clients open their own connections and do not use these named clients yet.
A provider that creates Microsoft.Extensions.AI clients implements IAIClientProvider (CanHandle(clientName) plus GetChatClientAsync, GetEmbeddingGeneratorAsync, GetRealtimeClientAsync and the other client getters for a connection), so IAIClientFactory, capability enforcement and metering apply to it with no extra code. A provider that owns the whole completion loop implements IAICompletionClient (ClientName, CompleteAsync, CompleteStreamingAsync) and registers it with AddCoreAICompletionClient<TClient>(clientName, configure). Deriving from AICompletionServiceBase gives ResolveDeploymentAsync(slotName, providerName, deploymentName) and ResolveRequestDeploymentAsync(context, providerName), which honors AICompletionContext.IsUtilityCompletion.
ResolveSlotAsync returns null: no deployment declares the slot's required feature, or the only candidate declares the excluded realtime feature for Chat or Utility.Features, its ClientName is unknown, or one of its values could not be read (each bad entry is now skipped on its own with an error naming it).toolCalling, so capability enforcement removes them and logs a warning.The provider clients take an IHttpClientFactory, and their static caches are gone. Code that constructs OpenAIClientProvider, OllamaAIClientProvider, AzureOpenAIClientProvider or AzureOpenAICompletionClient passes an IHttpClientFactory and an AIProviderClientCache; AzureAIInferenceClientProvider and ClaudeClientService take an IHttpClientFactory. OpenAIClientProvider.ClearCache() and OllamaAIClientProvider.ClearCache() become Clear() on the AIProviderClientCache from the container.
OAuth2 token requests (DefaultOAuth2TokenService) no longer follow redirects, and AddCoreAIServices() registers them through AddCoreAIOAuth2TokenService(); see crestapps-core-mcp.
The packages target net10.0 and net11.0. On net11.0, Microsoft.Extensions.AI and Microsoft.Extensions.AI.Abstractions resolve to 11.0.0 (10.11.0 on net10.0); Microsoft.Extensions.AI.OpenAI stays on 10.9.0 for both.
Conversation history now carries tool calls and results (stored as ChatTurnToolActivity on the assistant message); a custom completion client should pass ChatRole.Tool messages through to its provider.
ProviderAICompletionClient<TProvider> takes the scoped DefaultAIOptions instead of IOptions<DefaultAIOptions>, so a site's telemetry settings reach the OpenAI, Azure AI Inference and Ollama clients. Code that constructs it directly passes a DefaultAIOptions. A client registered with AddCoreAICompletionClient needs no change.
AIDeploymentPurpose, AIDeploymentPurposeExtensions, AIDeploymentType, AIDeployment.Purpose, AIDeployment.Type, SupportsPurpose, SupportsType and CanServeTextCompletion() are removed.ResolveOrDefaultAsync(AIDeploymentPurpose.X, ...) becomes ResolveSlotAsync(AIDeploymentSlotNames.X, ...). GetByPurposeAsync, GetAllByPurposeAsync, GetByTypeAsync, GetAllByTypeAsync and the purpose overloads of GetDefaultAsync become GetAllBySlotAsync. ResolveAsync(purpose, ...) becomes ResolveSlotOrThrowAsync(slotName, ...).AIDeploymentConfigurationEntry.Purpose and .Type become LegacyPurposes. Replace "Purpose" or "Type" keys in configuration with Features.Purpose, Capability or Type are projected onto capabilities when read, so no data migration is needed. The projection maps Chat/Utility to textGeneration only, so declare toolCalling and streaming yourself or tools are stripped.AICompletionServiceBase.ResolveDeploymentAsync takes a slot name instead of a purpose.ChatMode.Realtime and AIProfile.RealtimeDeploymentName are removed; a realtime model is a deployment that declares realtime.What SKILL.md sets; muted values are Claude Code's defaults
/crestapps-core:crestapps-core-ai-runtimefrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs.Other plugins' skills for the same job