Chat
Use the chat API for conversational AI, text generation, and completions.
The chat API provides access to conversational AI capabilities. Use it for text generation, question answering, content creation, and more.
IAIChatService
The primary interface for chat operations:
public interface IAIChatService
{
// Non-streaming responses
Task<ChatResponse> GetChatResponseAsync(
Action<AIChatBuilder> configure,
IEnumerable<ChatMessage> messages,
CancellationToken cancellationToken = default);
// Streaming responses
IAsyncEnumerable<ChatResponseUpdate> StreamChatResponseAsync(
Action<AIChatBuilder> configure,
IEnumerable<ChatMessage> messages,
CancellationToken cancellationToken = default);
// Advanced: Create the underlying client
Task<IChatClient> CreateChatClientAsync(
Action<AIChatBuilder> configure,
CancellationToken cancellationToken = default);
}Basic Usage
Message Roles
Role
Description
ChatRole.System
Instructions for the AI (set behavior, context)
ChatRole.User
Messages from the user
ChatRole.Assistant
Previous responses from the AI
ChatRole.Tool
Results from tool/function calls
Multi-Turn Conversations
Include previous messages to maintain context:
Choosing a Profile
Default Profile
Once you have configured a default chat profile in the backoffice, you can call without specifying a profile:
Specific Profile
Pass the profile ID using the builder:
Or use the profile alias directly:
In This Section
Basic ChatStreamingSystem PromptsAdvanced OptionsLast updated
Was this helpful?