ChatClientExtensions

Helpers & Utilities · AiDotNet.Agentic.Models

Convenience helpers over IChatClient for the common “prompt in, text out” case.

For Beginners

Instead of constructing a list of messages and reading a response object, you can write await client.GenerateTextAsync("Summarize this") and get a plain string back.

How It Works

The agentic model layer is message-based, but plenty of callers (and internal consumers such as the reasoning strategies) just want to send a prompt and read back text. These extensions wrap a single user message and return the assistant’s concatenated text, so simple call sites stay simple while the full message/tool/streaming API remains available when needed.

Methods

Method Summary
Task<string> GenerateResponseAsync(IChatClient<T> client, string prompt, CancellationToken cancellationToken) Sends a single user prompt and returns the assistant’s text reply.
Task<string> GenerateTextAsync(IChatClient<T> client, string prompt, ChatOptions options, CancellationToken cancellationToken) Sends a single user prompt and returns the assistant’s text reply.
Task<string> GenerateTextAsync(IChatClient<T> client, string systemPrompt, string userPrompt, ChatOptions options, CancellationToken cancellationToken) Sends a system instruction plus a user prompt and returns the assistant’s text reply.