Interface IAIService
Core abstraction for AI completion and streaming services. Implement this interface to create custom AI service providers.
public interface IAIService
- Extension Methods
Properties
ActivateChat
The currently active chat block containing conversation history.
ChatBlock ActivateChat { get; }
Property Value
Model
The AI model identifier currently in use.
string Model { get; }
Property Value
Provider
The AI provider name (e.g., "OpenAI", "Anthropic").
string Provider { get; }
Property Value
StatelessMode
When true, each request is processed independently without maintaining conversation history.
bool StatelessMode { get; set; }
Property Value
SystemMessage
System message for the active chat.
string SystemMessage { get; set; }
Property Value
Methods
GetCompletionAsync(Message, AIRequestProfile?, AIRequestContext?, CancellationToken)
Returns the final response, canceling transport and cooperative local work when requested.
Task<string> GetCompletionAsync(Message message, AIRequestProfile? profile = null, AIRequestContext? context = null, CancellationToken cancellationToken = default)
Parameters
messageMessageprofileAIRequestProfilecontextAIRequestContextcancellationTokenCancellationToken
Returns
Remarks
Cancellation does not guarantee remote generation or billing stops.
GetCompletionAsync(string, AIRequestProfile?, AIRequestContext?, CancellationToken)
Returns the final response, canceling transport and cooperative local work when requested.
Task<string> GetCompletionAsync(string prompt, AIRequestProfile? profile = null, AIRequestContext? context = null, CancellationToken cancellationToken = default)
Parameters
promptstringprofileAIRequestProfilecontextAIRequestContextcancellationTokenCancellationToken
Returns
Remarks
Cancellation does not guarantee remote generation or billing stops.
StreamAsync(Message, AIRequestContext?, CancellationToken)
IAsyncEnumerable<string> StreamAsync(Message message, AIRequestContext? context = null, CancellationToken cancellationToken = default)
Parameters
messageMessagecontextAIRequestContextcancellationTokenCancellationToken
Returns
Remarks
Planned for withdrawal from the public API in the next major release, once the replacement is available.
This API remains supported during the minor transition. Use StartRunAsync and the returned run's output stream for new integrations.
Execution logic will be preserved behind non-public implementation hooks.
StreamAsync(Message, StreamOptions, AIRequestContext?, CancellationToken)
IAsyncEnumerable<StreamingContent> StreamAsync(Message message, StreamOptions options, AIRequestContext? context = null, CancellationToken cancellationToken = default)
Parameters
messageMessageoptionsStreamOptionscontextAIRequestContextcancellationTokenCancellationToken
Returns
Remarks
Planned for withdrawal from the public API in the next major release, once the replacement is available.
This API remains supported during the minor transition. Use StartRunAsync and the returned run's output stream for new integrations.
Execution logic will be preserved behind non-public implementation hooks.
StreamAsync(string, StreamOptions, CancellationToken)
IAsyncEnumerable<StreamingContent> StreamAsync(string prompt, StreamOptions options, CancellationToken cancellationToken = default)
Parameters
promptstringoptionsStreamOptionscancellationTokenCancellationToken
Returns
Remarks
Planned for withdrawal from the public API in the next major release, once the replacement is available.
This API remains supported during the minor transition. Use StartRunAsync and the returned run's output stream for new integrations.
Execution logic will be preserved behind non-public implementation hooks.
StreamAsync(string, CancellationToken)
IAsyncEnumerable<string> StreamAsync(string prompt, CancellationToken cancellationToken = default)
Parameters
promptstringcancellationTokenCancellationToken
Returns
Remarks
Planned for withdrawal from the public API in the next major release, once the replacement is available.
This API remains supported during the minor transition. Use StartRunAsync and the returned run's output stream for new integrations.
Execution logic will be preserved behind non-public implementation hooks.