Orchard Core AI Services
CrestApps.OrchardCore.AI is the Orchard foundation of the CrestApps AI suite. It wires the shared
CrestApps.Core AI services into Orchard Core and adds connection, deployment, profile, template, tool
instance and persona management, AI site settings, recipes, deployment steps and workflow activities.
Guidelines
- Install
CrestApps.OrchardCore.AIand at least one provider package (CrestApps.OrchardCore.OpenAI,
CrestApps.OrchardCore.OpenAI.Azure, CrestApps.OrchardCore.AzureAIInference, CrestApps.OrchardCore.Ollama)
in the web/startup project.
CrestApps.OrchardCore.AIis dependency-only: a provider or a feature such as AI Chat enables it.- A connection holds credentials, a deployment is one model used through a connection and declares
model capabilities, and an AI profile names deployments by technical name. Where a deployment is
used is a slot (chat, utility, embedding, ...) resolved from site defaults. See
orchardcore-ai-model-capabilities.
- Never hardcode API keys. Use user secrets in development and environment variables or Azure Key Vault in
production.
- Read settings-backed AI options through
IOptionsMonitor<T>.CurrentValue, neverIOptions<T>. - The service APIs (
IAIClientFactory,IAICompletionService,IAIProfileManager, orchestration) live in
CrestApps.Core. Use crestapps-core-ai-profiles and crestapps-core-ai-runtime for framework detail.
- All recipe JSON uses the root
{ "steps": [ ... ] }format, and C# classes aresealed(except view models).
Features
| Feature ID | Name | Notes |
| --- | --- | --- |
| CrestApps.OrchardCore.AI | AI Services | Dependency only. Deployments, profiles, profile templates, AI settings, the Cascaded Realtime deployment provider |
| CrestApps.OrchardCore.AI.Chat.Core | AI Chat Services | Dependency only. Chat sessions, session processing, response-handler selection. Depends on CrestApps.OrchardCore.AI.Prompting |
| CrestApps.OrchardCore.AI.Chat.Api | AI Chat WebAPI | REST endpoints for chat and completion, and the AG-UI endpoint POST /api/ai/v1/agui (with AI Chat; see orchardcore-ai-chat) |
| CrestApps.OrchardCore.AI.ConnectionManagement | AI Connection Management | Provider connection editor and the AIProviderConnections recipe step. See orchardcore-ai-connections |
| CrestApps.OrchardCore.AI.ToolInstances | AI Tool Instances | See orchardcore-ai-tool-instances |
| CrestApps.OrchardCore.AI.Personas | AI Personas | See orchardcore-ai-personas |
| CrestApps.OrchardCore.AI.UsageAnalytics | AI Usage Analytics | Records AI usage and adds the AI Usage Analytics report. See orchardcore-ai-usage-analytics |
| CrestApps.OrchardCore.AI.Quality | AI Quality | Simulation test cases, QA cohorts, the AI QA Dashboard report and alert rules. See orchardcore-ai-conversations |
| CrestApps.OrchardCore.AI.Webhooks | AI Webhooks | Offers AI events to the Webhooks feature (CrestApps.OrchardCore.Webhooks). See orchardcore-ai-conversations |
| CrestApps.OrchardCore.AI.CustomLlm | Custom LLM (WebSocket) | A provider that streams turns from your own WebSocket server. See orchardcore-ai-providers |
{
"steps": [
{
"name": "Feature",
"enable": [
"CrestApps.OrchardCore.AI.ConnectionManagement",
"CrestApps.OrchardCore.OpenAI",
"CrestApps.OrchardCore.AI.Chat"
],
"disable": []
}
]
}
Admin screens and permissions
| Screen | Permission |
| --- | --- |
| Artificial Intelligence > Provider Connections | ManageProviderConnections |
| Artificial Intelligence > Deployments | ManageAIDeployments |
| Artificial Intelligence > Profiles | ManageAIProfiles |
| Artificial Intelligence > Templates | ManageAIProfileTemplates |
| Artificial Intelligence > Tool Instances | ManageAIToolInstances |
| Artificial Intelligence > Personas | ManageAIPersonas |
| Artificial Intelligence > Speaking Styles, Guardrail Topics | ManageAIProfileTemplates (they are System Prompt templates in their own categories) |
| Artificial Intelligence > Voice library | ManageAIDeployments |
| Artificial Intelligence > API keys (AI Chat WebAPI) | ManageAIApiKeys |
| Artificial Intelligence > Tests, QA, Alert rules (AI Quality) | ManageAIQuality |
| Settings > Artificial Intelligence (group ai-settings) | ManageAIProfiles, plus the permission each feature's card registers |
AI Webhooks subscriptions are managed on Settings > Webhooks with the Webhooks module's Manage webhooks permission (stored name ManageCommerceWebhooks); the old Manage AI webhooks permission is no longer registered, and AIWebhookIndexMigrations carries roles that held it over to ManageCommerceWebhooks. Every saved profile is a version under the profile's
Versions page (see orchardcore-ai-conversations).
Permissions are declared in AIPermissions with LocalizationSource.Create(...) descriptions. Every list
(profiles AIProfiles, deployments AIDeployments, connections AIProviderConnections, templates
AITemplates, tool instances AIToolInstances, personas AIPersonas) renders through Orchard Core's
AdminList shape; configuration-backed deployments and connections render in a separate read-only list
(AIDeploymentsReadOnly, AIProviderConnectionsReadOnly). Rows are {Model}_SummaryAdmin (List layout)
and SummaryAdminGrid zones (Grid layout). See orchardcore-admin-lists to add columns or row actions.
Configuration (appsettings.json)
Connections and deployments are two sibling arrays under OrchardCore:CrestApps:AI. Configuration
entries appear beside stored ones and are read-only in the admin.
{
"OrchardCore": {
"CrestApps": {
"AI": {
"DefaultParameters": {
"Temperature": 0,
"MaxOutputTokens": 800,
"PastMessagesCount": 10,
"MaximumIterationsPerRequest": 10
},
"Connections": [
{
"Name": "openai-cloud",
"ClientName": "OpenAI",
"ApiKey": "<from a secret store>"
}
],
"Deployments": [
{
"Name": "chat-default",
"ClientName": "OpenAI",
"ConnectionName": "openai-cloud",
"ModelName": "gpt-4o",
"Properties": {
"AIDeploymentMetadata": {
"Features": [ "textGeneration", "toolCalling", "streaming" ]
}
}
},
{
"Name": "embedding-default",
"ClientName": "OpenAI",
"ConnectionName": "openai-cloud",
"ModelName": "text-embedding-3-large",
"Properties": {
"AIDeploymentMetadata": {
"Features": [ "textEmbedding" ]
}
}
}
]
}
}
}
}
DefaultParameters keys are Temperature, MaxOutputTokens, TopP, FrequencyPenalty, PresencePenalty,
PastMessagesCount, MaximumIterationsPerRequest (default 10), AbsoluteMaximumIterationsPerRequest
(100), EnableOpenTelemetry and EnableDistributedCaching. Environment variables use __, for example
OrchardCore__CrestApps__AI__Connections__0__ApiKey. The old CrestApps_AI:DefaultParameters and
CrestApps_AI:Providers sections are still read; use the names above for new configuration.
Per-provider connection keys are in orchardcore-ai-providers.
AI site settings
Settings > Artificial Intelligence is built from cards contributed by enabled features.
| Settings class (recipe key) | Holds | Read through |
| --- | --- | --- |
| GeneralAISettings | EnablePreemptiveMemoryRetrieval, OverrideMaximumIterationsPerRequest/MaximumIterationsPerRequest, OverrideEnableDistributedCaching/EnableDistributedCaching, OverrideEnableOpenTelemetry/EnableOpenTelemetry | IOptionsMonitor<GeneralAIOptions> |
| DefaultAIDeploymentSettings | DefaultChatDeploymentName, DefaultUtilityDeploymentName, DefaultEmbeddingDeploymentName, DefaultImageDeploymentName, DefaultVisionDeploymentName, DefaultSpeechToTextDeploymentName, DefaultTextToSpeechDeploymentName, DefaultTextToSpeechVoiceId, DefaultRealtimeDeploymentName | the slot resolver |
{
"steps": [
{
"name": "Settings",
"GeneralAISettings": {
"EnablePreemptiveMemoryRetrieval": false,
"OverrideMaximumIterationsPerRequest": true,
"MaximumIterationsPerRequest": 20
},
"DefaultAIDeploymentSettings": {
"DefaultChatDeploymentName": "chat-default",
"DefaultUtilityDeploymentName": "chat-default",
"DefaultEmbeddingDeploymentName": "embedding-default"
}
}
]
}
On the General card, Maximum iterations, Distributed caching and Enable OpenTelemetry show the
value in effect. A saved value overrides configuration (CrestApps:AI:DefaultParameters) only when it differs from
it: saving sets the matching Override... flag, and a value equal to configuration keeps following configuration.
(Before #1306 the flags were never set, so saved values had no effect.) In a recipe, set the Override... flag
together with the value.
Usage tracking is no longer a setting: enable the CrestApps.OrchardCore.AI.UsageAnalytics feature. The
Costs card and AICostSettings are gone: model prices are on each deployment's Pricing card, and the
carrier's call price is on the Costs tab of Settings → Communication → Telephony (TelephonyCostSettings;
see orchardcore-ai-usage-analytics and orchardcore-telephony).
Saving General no longer reloads the tenant: GeneralAIOptions is refreshed live through
AddSignalOptionsChangeTokenSource<GeneralAIOptions>(). Code that reads it must use
IOptionsMonitor<GeneralAIOptions> (see orchardcore-site-settings).
Deployments by recipe
{
"steps": [
{
"name": "AIDeployment",
"Deployments": [
{
"Name": "chat-default",
"ModelName": "gpt-4o",
"ClientName": "OpenAI",
"ConnectionName": "openai-cloud",
"Properties": {
"AIDeploymentMetadata": {
"Features": [ "textGeneration", "toolCalling", "streaming", "structuredOutputs" ]
}
}
}
]
}
]
}
- An existing deployment is matched by
ItemId, or byNameplusClientName. - The step reads
Deployments(and the legacydeployments); the AI Deployments deployment step now
writes Deployments, so an exported plan validates against the recipe schema.
- A capability list in
Propertiesreplaces the stored list on re-import instead of being appended. - A
Pricingsection (Currency,Prices) sets the deployment's prices; omit it to keep them,nullremoves
them. See orchardcore-ai-usage-analytics.
- A deployment that declares no capabilities and carries no legacy
Purposeis imported as
textGeneration only. Declare toolCalling and streaming explicitly for a chat model.
- Remove deployments with
{ "name": "DeleteAIDeployments", "DeploymentNames": [ "old-chat" ] }or
"IncludeAll": true.
- There is no
IsDefaulton a deployment any more. Defaults are theDefaultAIDeploymentSettingsabove.
AI profiles
| Type | Purpose |
| --- | --- |
| Chat | An assistant people talk to (chat page, widget, automated SMS and voice) |
| Utility | Background work invoked from code or workflows |
| TemplatePrompt | A prompt run against an existing chat session (PromptTemplate, PromptSubject) |
| Agent | A specialist other profiles call as a tool. Description is required |
Profile by recipe
{
"steps": [
{
"name": "AIProfile",
"Profiles": [
{
"Name": "support-assistant",
"DisplayText": "Support Assistant",
"Type": "Chat",
"TitleType": "Generated",
"WelcomeMessage": "How can I help?",
"ChatDeploymentName": "chat-default",
"UtilityDeploymentName": "chat-default",
"Properties": {
"AIProfileMetadata": {
"SystemMessage": "You are a helpful support assistant.",
"Temperature": 0.3,
"MaxTokens": 2048,
"PastMessagesCount": 10
},
"FunctionInvocationMetadata": { "Names": [] },
"AgentInvocationMetadata": { "Names": [ "research-agent" ] },
"PromptTemplateMetadata": {
"Templates": [ { "TemplateId": "customer-support-tone" } ]
},
"AIDeploymentParametersMetadata": {
"Values": { "reasoningEffort": "Medium" }
}
},
"Settings": {
"AIChatProfileSettings": { "IsOnAdminMenu": true },
"ChatModeProfileSettings": { "ChatMode": "TextInput" }
}
}
]
}
]
}
- The step is source-agnostic: omit
Sourceand name deployments withChatDeploymentNameand
UtilityDeploymentName. Leave them empty to use the site defaults.
TitleTypeisInitialPromptorGenerated.AIDeploymentParametersMetadata.Values(chat deployment) and.UtilityValues(utility deployment) hold
model parameter choices; a parameter the deployment does not declare is never sent.
AIProfileMetadata.InitialPromptis the Opening message (UI label "Start the conversation
automatically"); the property name did not change.
ChatModeProfileSettingsholdsChatMode(TextInput,AudioInput,Conversation),
ConversationDeploymentName, VoiceName and EnableTextToSpeechPlayback. See
orchardcore-ai-realtime-voice.
- For an
Agent, add"AgentMetadata": { "Availability": "OnDemand" }(orAlwaysAvailable) toProperties. - To start from a profile template use
CreateAIProfileFromTemplate(orchardcore-ai-profile-templates).
Profile in a migration
using CrestApps.Core.AI.Models;
using CrestApps.Core.AI.Profiles;
using OrchardCore.Data.Migration;
public sealed class SupportProfileMigrations : DataMigration
{
private readonly IAIProfileManager _profileManager;
public SupportProfileMigrations(IAIProfileManager profileManager)
{
_profileManager = profileManager;
}
public async Task<int> CreateAsync()
{
var profile = await _profileManager.NewAsync();
profile.Name = "support-assistant";
profile.DisplayText = "Support Assistant";
profile.Type = AIProfileType.Chat;
profile.WithSettings(new AIProfileSettings
{
LockSystemMessage = true,
IsRemovable = false,
});
profile.AlterSettings<ChatModeProfileSettings>(settings =>
{
settings.ChatMode = ChatMode.TextInput;
});
profile.Put(new AIProfileMetadata
{
SystemMessage = "You are a helpful support assistant.",
Temperature = 0.3f,
MaxTokens = 2048,
});
await _profileManager.CreateAsync(profile);
return 1;
}
}
Settings classes (AIProfileSettings, ChatModeProfileSettings, ResponseHandlerProfileSettings,
AIChatProfileSettings) live on profile.Settings: read them with GetSettings<T>()/TryGetSettings<T>()
and write them with WithSettings/AlterSettings<T>(). Metadata (AIProfileMetadata, AgentMetadata,
PromptTemplateMetadata) lives on Properties: use Put, TryGet and GetOrCreate.
IAIProfileManager is an INamedCatalogManager<AIProfile>: NewAsync, ValidateAsync, CreateAsync,
UpdateAsync, FindByNameAsync, DeleteAsync, plus GetAsync(AIProfileType). There is no SaveAsync.
Register the migration with services.AddDataMigration<SupportProfileMigrations>(). Framework-level profile
construction is covered by crestapps-core-ai-profiles.
Resolving deployments and clients in code
Pick a deployment for a slot, then create the client from it. The purpose-based APIs are gone.
using CrestApps.Core.AI.Clients;
using CrestApps.Core.AI.Deployments;
using CrestApps.Core.AI.Models;
public sealed class TranscriptionService
{
private readonly IAIDeploymentManager _deploymentManager;
private readonly IAIClientFactory _clientFactory;
public TranscriptionService(IAIDeploymentManager deploymentManager, IAIClientFactory clientFactory)
{
_deploymentManager = deploymentManager;
_clientFactory = clientFactory;
}
public async Task<string> TranscribeAsync(Stream audio, string deploymentName = null)
{
var deployment = await _deploymentManager.ResolveSlotAsync(
AIDeploymentSlotNames.SpeechToText,
deploymentName: deploymentName);
if (deployment is null)
{
return null;
}
using var client = await _clientFactory.CreateSpeechToTextClientAsync(deployment);
var response = await client.GetTextAsync(audio);
return response.Text;
}
}
ResolveSlotAsync(slot, deploymentName, clientName, fallbackDeploymentNames, cancellationToken)walks
the requested name, the site default for the slot, the fallback slot (utility falls back to chat), then
the first capable deployment.
IAIClientFactorycreates chat clients, embedding generators, image generators, speech-to-text,
text-to-speech and realtime clients from an AIDeployment. Each overload accepts a builder callback,
for example builder => builder.UseDefaultResilience().UseUsageLabels(purpose: "MyPurpose").
- Voices for a text-to-speech deployment come from
ISpeechVoiceResolver.GetSpeechVoicesAsync(deployment). - Slots, capabilities and the deployment pickers are covered by
orchardcore-ai-model-capabilities;
usage labels by orchardcore-ai-usage-analytics.
Recipes and deployment steps
| Recipe step | Deployment step (title) | Export selector |
| --- | --- | --- |
| AIProviderConnections | AI Provider Connections | ConnectionIds |
| AIDeployment | AI Deployments | DeploymentNames |
| DeleteAIDeployments | Delete AI Deployments | DeploymentNames |
| AIProfile | AI Profiles | ProfileNames |
| AIProfileTemplate, CreateAIProfileFromTemplate | AI Profile Templates | TemplateNames |
| AIToolInstances | AI Tool Instances | InstanceIds |
| AIPersonas | AI Personas | PersonaIds |
Every deployment step supports IncludeAll. Exported connections have their API keys blanked. The
CrestApps Recipes feature publishes the JSON schemas of these steps (see orchardcore-crestapps-recipes).
Upgrading from 2.x
AIDeploymentPurpose,AIDeploymentType,AIDeployment.Purpose/Type,IsDefault,
GetByPurposeAsync, GetAllByPurposeAsync and ResolveOrDefaultAsync(purpose, ...) are removed. Use
GetAllBySlotAsync(AIDeploymentSlotNames.X) and ResolveSlotAsync(AIDeploymentSlotNames.X, ...).
- Replace
"Purpose"in recipes andappsettings.jsonwithProperties.AIDeploymentMetadata.Features.
Stored records with a legacy purpose keep working because they are projected onto capabilities on read.
ChatMode.RealtimeandRealtimeDeploymentNameare removed; a spoken conversation uses
ChatModeProfileSettings.ConversationDeploymentName with ChatMode.Conversation.
- Read
GeneralAIOptionsthroughIOptionsMonitor<GeneralAIOptions>;IOptions<T>never sees a settings change. - The profile editor's Apply Templates card is gone; Add Profile opens the New AI Profile picker.
- Admin list overrides must target the
AdminListshapes; a driver that adds a row shape must also give it a
SummaryAdminGrid location.
- Admin create and edit forms render their buttons in Orchard Core's sticky
<div class="action-bar-bottom">
instead of an ocat-wrapper / ocat-end-offset row; update overridden editor views and UI tests.
EnableAIUsageTracking,AICostSettings(with its recipe schema) and the Costs card are removed (see AI site settings above).- The AI modules report OpenTelemetry metrics and spans on the
CrestApps.OrchardCore.AImeter (data source syncs, evaluations, alerts, tool timeouts, signed webhooks); the chat pipeline is measured by CrestApps.Core. Seeorchardcore-observability. - A record an upgrade migration cannot move is skipped and logged (
MigrationSkipReport), with a dismissible
admin warning for people with ManageAIProfiles; other modules join through services.AddMigrationSkipLog().
Related skills
orchardcore-ai-connectionsandorchardcore-ai-providersfor connections and provider setup.orchardcore-ai-model-capabilitiesfor capabilities, parameters and slots.orchardcore-ai-usage-analyticsfor metered usage and the AI Usage Analytics report.orchardcore-ai-profile-templatesandorchardcore-ai-promptingfor templates.orchardcore-ai-chat,orchardcore-ai-chat-interactions,orchardcore-ai-realtime-voicefor chat surfaces.orchardcore-ai-tools,orchardcore-ai-agentandorchardcore-ai-workflowsfor tools, agents and workflows.orchardcore-ai-conversationsfor conversation workflows, quality, guardrails, privacy and the AI API.crestapps-core-ai-profilesandcrestapps-core-ai-runtimefor the CrestApps.Core APIs.orchardcore-observabilityfor the AI telemetry and turning OpenTelemetry on.