Table of Contents

Class ChatCompletionRequestBase<TSelf, TPrompt, TOutput>

Task for generating text using an LLM model. Supports instructions and role-based prompts.

public abstract class ChatCompletionRequestBase<TSelf, TPrompt, TOutput> : LanguageModelRequest<TSelf, TPrompt, TOutput>, ILanguageModelRequest, IGenerativeRequest, ISequentialRequest where TSelf : ChatCompletionRequestBase<TSelf, TPrompt, TOutput> where TPrompt : IPrompt where TOutput : IGeneratedOutput

Type Parameters

TSelf
TPrompt
TOutput
Inheritance
object
FluentApiRequest<TSelf, TOutput>
GenerativeRequest<TSelf, TPrompt, TOutput, string, INoopStreamEvent<TOutput>>
LanguageModelRequest<TSelf, TPrompt, TOutput>
ChatCompletionRequestBase<TSelf, TPrompt, TOutput>
Implements
Derived
Inherited Members
Extension Methods

Constructors

ChatCompletionRequestBase()

protected ChatCompletionRequestBase()

ChatCompletionRequestBase(TPrompt)

protected ChatCompletionRequestBase(TPrompt prompt)

Parameters

prompt TPrompt

Properties

Messages

Context messages for chat-based models.

public List<Message> Messages { get; set; }

Property Value

List<Message>

OutputModalities

For multi-modal models, specifies the desired output modalities (e.g., text, image, audio).
Note: Not all providers support this parameter. Check your provider's documentation for details.

public Modalities? OutputModalities { get; set; }

Property Value

Modalities?

Stop

Stop sequences for text generation.
Note: Responses API does not support this parameter.

public List<string> Stop { get; set; }

Property Value

List<string>

Methods

AddMessageRange(IEnumerable<Message>)

public override TSelf AddMessageRange(IEnumerable<Message> messages)

Parameters

messages IEnumerable<Message>

Returns

TSelf

CreateStreamAsyncInternal()

protected override UniTask<IO.Networking.RESTApi.IRESTStream<INoopStreamEvent<TOutput>>> CreateStreamAsyncInternal()

Returns

UniTask<IRESTStream<INoopStreamEvent<TOutput>>>

GetMessages()

public override List<Message> GetMessages()

Returns

List<Message>

SetOutputModalities(Modalities)

Sets the desired output modalities for multi-modal models (e.g., text, image, audio). Note: Not all providers support this parameter. Check your provider's documentation for details.

public TSelf SetOutputModalities(Modalities modalities)

Parameters

modalities Modalities

Returns

TSelf

SetResponseFormat(ResponseFormat)

Sets the desired response format for the output.

  • Auto: Model decides the best format.
  • Text: Plain text output.
  • JsonObject: Structured JSON output.
You can also use 'JsonSchemaFormat' which extends ResponseFormat to specify a strict JSON schema for structured output. Note: Not all providers support response format control. Check your provider's documentation for details.
public TSelf SetResponseFormat(ResponseFormat format)

Parameters

format ResponseFormat

Returns

TSelf

SetResponseFormat(Type)

Sets the desired response format using a type annotated with JsonSchemaAttribute or StrictJsonSchemaAttribute. The type's structure will be converted into a JSON schema for the model to follow.

public TSelf SetResponseFormat(Type type)

Parameters

type Type

Returns

TSelf

SetStopSequences(params string[])

Sets the stop sequences for text generation.
Note: Responses API does not support this parameter.

public TSelf SetStopSequences(params string[] stop)

Parameters

stop string[]

Returns

TSelf