Overview
Learn how to use Umbraco.AI services in your code for chat, embeddings, and more.
Umbraco.AI provides a service layer that wraps Microsoft.Extensions.AI types with Umbraco-specific features like profiles and connections. This section covers how to use these services in your code.
Primary Services
IAIChatService
Chat completions and conversational AI
IAIEmbeddingService
Generate vector embeddings for text
Dependency Injection (DI)
All services are registered automatically and can be injected into your controllers, services, and components:
public class MyController : UmbracoApiController
{
private readonly IAIChatService _chatService;
private readonly IAIEmbeddingService _embeddingService;
public MyController(
IAIChatService chatService,
IAIEmbeddingService embeddingService)
{
_chatService = chatService;
_embeddingService = embeddingService;
}
}Using M.E.AI Types
Umbraco.AI uses standard Microsoft.Extensions.AI (M.E.AI) types:
ChatMessage
Microsoft.Extensions.AI
A message in a conversation
ChatRole
Microsoft.Extensions.AI
User, Assistant, System, Tool
ChatResponse
Microsoft.Extensions.AI
Complete response from chat
ChatResponseUpdate
Microsoft.Extensions.AI
Streaming response chunk
ChatOptions
Microsoft.Extensions.AI
Request options (temperature, and so on)
Quick Examples
Chat Completion
Streaming Chat
Generate Embedding
In This Section
ChatEmbeddingsToolsLast updated
Was this helpful?