Class GenerativeTextRequest<TSelf, TInput, TResult, TEvent>
Base class for text generation tasks using LLM models. Supports instructions, role-based prompts, and attachments.
Inheritance
GenerativeTextRequest<TSelf, TInput, TResult, TEvent>
Assembly: Glitch9.AIDevKit.dll
Syntax
public abstract class GenerativeTextRequest<TSelf, TInput, TResult, TEvent> : StreamingGenerativeRequest<TSelf, TInput, TResult, TEvent, ITextRequestOptions>, IStreamingGenerativeRequest<TEvent, TResult>, IGenerativeTextRequest, IGenerativeRequest where TSelf : GenerativeTextRequest<TSelf, TInput, TResult, TEvent> where TInput : IPrompt where TResult : class
Type Parameters
| Name |
Description |
| TSelf |
|
| TInput |
|
| TResult |
|
| TEvent |
|
Constructors
|
Edit this page
View Source
GenerativeTextRequest()
Declaration
protected GenerativeTextRequest()
|
Edit this page
View Source
GenerativeTextRequest(TInput)
Declaration
protected GenerativeTextRequest(TInput prompt)
Parameters
| Type |
Name |
Description |
| TInput |
prompt |
|
Properties
|
Edit this page
View Source
FrequencyPenalty
Penalizes frequent repetition of the same token sequence.
Range: -2.0 - 2.0 (typical: 0.0).
Declaration
public FrequencyPenalty FrequencyPenalty { get; set; }
Property Value
|
Edit this page
View Source
Instructions
Optional. A system (or developer) message inserted into the model's context.
Declaration
public string Instructions { get; set; }
Property Value
|
Edit this page
View Source
LogitBias
Biases specific tokens by ID. Use to influence token selection.
Key = token ID (as string), Value = bias (-100 to 100, 0 = no bias).
Declaration
public Dictionary<string, double> LogitBias { get; set; }
Property Value
|
Edit this page
View Source
Logprobs
Whether to return log probabilities of the Output tokens or not.
If true, returns the log probabilities of each Output token returned in the content of message.
This option is currently not available on the gpt-4-vision-preview model.
Declaration
public bool? Logprobs { get; set; }
Property Value
|
Edit this page
View Source
MaxTokens
Optional. An upper bound for the number of tokens that can be generated for a response.
Declaration
public TokenCount MaxTokens { get; set; }
Property Value
|
Edit this page
View Source
ModelType
Declaration
public override ModelType ModelType { get; }
Property Value
Overrides
|
Edit this page
View Source
ParallelToolCalls
Optional. Defaults to true.
Whether to allow the model to run tool calls in parallel.
Declaration
public bool? ParallelToolCalls { get; set; }
Property Value
|
Edit this page
View Source
PresencePenalty
Penalizes tokens already present in the generated content.
Range: -2.0 - 2.0 (typical: 0.0).
Declaration
public PresencePenalty PresencePenalty { get; set; }
Property Value
|
Edit this page
View Source
ReasoningOptions
Optional. Configuration options for reasoning models.
Declaration
public ReasoningOptions ReasoningOptions { get; set; }
Property Value
|
Edit this page
View Source
RequestMetadata
Optional. Metadata to include with the request.
Declaration
public ServerDictionary RequestMetadata { get; set; }
Property Value
|
Edit this page
View Source
ResponseFormat
Defines how the response should be formatted (e.g., text, JSON).
Declaration
public virtual ResponseFormat ResponseFormat { get; set; }
Property Value
|
Edit this page
View Source
SafetySettings
Safety filters that define moderation thresholds for the model output.
Declaration
public List<SafetySetting> SafetySettings { get; set; }
Property Value
|
Edit this page
View Source
StartingMessage
Optional. A conversation starter of the model's response.
Declaration
public string StartingMessage { get; set; }
Property Value
|
Edit this page
View Source
Stop
Stop sequences for text generation.
Note: Responses API does not support this parameter.
Declaration
public List<string> Stop { get; set; }
Property Value
|
Edit this page
View Source
StreamOptions
Optional. Defaults to null
Options for streaming responses. Only set this when you set stream: true.
Declaration
public StreamOptions StreamOptions { get; set; }
Property Value
|
Edit this page
View Source
Temperature
Optional. Defaults to 1
What sampling temperature to use, between 0 and 2.
Declaration
public Temperature Temperature { get; set; }
Property Value
|
Edit this page
View Source
ToolChoice
Optional. How the model should select which tool (or tools) to use when generating a response.
Declaration
public ToolChoice ToolChoice { get; set; }
Property Value
|
Edit this page
View Source
Tools
Optional. An array of tools the model may call while generating a response.
Declaration
public Tool[] Tools { get; set; }
Property Value
|
Edit this page
View Source
TopK
Samples the topK tokens with the highest probabilities.
Range is [1, 1000].
Default is 40.
Declaration
public TopK TopK { get; set; }
Property Value
|
Edit this page
View Source
TopLogprobs
Optional. An integer between 0 and 20 specifying the number of most likely tokens to return.
Declaration
public Logprobs TopLogprobs { get; set; }
Property Value
|
Edit this page
View Source
TopP
Optional. Defaults to 1
Nucleus sampling parameter.
Declaration
public TopP TopP { get; set; }
Property Value
|
Edit this page
View Source
WebSearchOptions
Declaration
public WebSearchSettings WebSearchOptions { get; set; }
Property Value
Methods
|
Edit this page
View Source
AddMessage(params Message[])
Adds context messages for chat-based models.
Declaration
public TSelf AddMessage(params Message[] messages)
Parameters
| Type |
Name |
Description |
| Message[] |
messages |
|
Returns
|
Edit this page
View Source
AddMessageRange(IEnumerable<Message>)
Declaration
public abstract TSelf AddMessageRange(IEnumerable<Message> messages)
Parameters
Returns
|
Edit this page
View Source
GetMessages()
Declaration
public abstract List<Message> GetMessages()
Returns
|
Edit this page
View Source
SetFrequencyPenalty(FrequencyPenalty)
Sets the frequency penalty parameter.
Declaration
public TSelf SetFrequencyPenalty(FrequencyPenalty frequencyPenalty)
Parameters
Returns
|
Edit this page
View Source
SetInstructions(string)
Sets the instruction for the task. This is a specific command or request for the model to follow.
Declaration
public TSelf SetInstructions(string instructions)
Parameters
| Type |
Name |
Description |
| string |
instructions |
|
Returns
|
Edit this page
View Source
SetLogitBias(Dictionary<string, double>)
Sets a custom token bias map.
Declaration
public TSelf SetLogitBias(Dictionary<string, double> logitBias)
Parameters
Returns
|
Edit this page
View Source
SetLogprobs(bool)
Enables returning token-level log probabilities.
Declaration
public TSelf SetLogprobs(bool logprobs)
Parameters
| Type |
Name |
Description |
| bool |
logprobs |
|
Returns
|
Edit this page
View Source
SetMaxOutputTokens(TokenCount)
Sets the maximum number of tokens the model can generate in its response.
Declaration
public TSelf SetMaxOutputTokens(TokenCount maxTokens)
Parameters
Returns
|
Edit this page
View Source
SetPresencePenalty(PresencePenalty)
Sets the presence penalty parameter.
Declaration
public TSelf SetPresencePenalty(PresencePenalty presencePenalty)
Parameters
Returns
|
Edit this page
View Source
SetReasoning(ReasoningEffort, TokenCount, bool)
OpenRouter style reasoning configuration.
Declaration
public TSelf SetReasoning(ReasoningEffort effort, TokenCount budgetTokens, bool exclude)
Parameters
Returns
|
Edit this page
View Source
SetReasoning(ReasoningEffort, ReasoningSummaryLevel?)
Configures the reasoning settings for the task.
For Anthropic models, use 'SetReasoning(TokenCount budgetTokens)' instead.
Declaration
public TSelf SetReasoning(ReasoningEffort effort, ReasoningSummaryLevel? summaryLevel = null)
Parameters
Returns
|
Edit this page
View Source
SetReasoning(ReasoningFormat)
GroqCloud-specific parameter to set the reasoning output format.
Declaration
public TSelf SetReasoning(ReasoningFormat format)
Parameters
| Type |
Name |
Description |
| ReasoningFormat |
format |
Specifies how to output reasoning tokens
|
Returns
|
Edit this page
View Source
SetReasoning(TokenCount)
Anthropic-specific parameter to set the reasoning budget in tokens.
Declaration
public TSelf SetReasoning(TokenCount budgetTokens)
Parameters
| Type |
Name |
Description |
| TokenCount |
budgetTokens |
Required. Determines how many tokens Claude can use for its internal reasoning process. Larger budgets
can enable more thorough analysis for complex problems, improving response quality.
|
Returns
|
Edit this page
View Source
SetReasoningOptions(ReasoningOptions)
Configures the reasoning settings for the task.
Declaration
public TSelf SetReasoningOptions(ReasoningOptions reasoningOptions)
Parameters
Returns
|
Edit this page
View Source
SetRequestMetadata(ServerDictionary)
Sets the stop sequences for text generation.
Declaration
public TSelf SetRequestMetadata(ServerDictionary metadata)
Parameters
Returns
|
Edit this page
View Source
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.
Declaration
public TSelf SetResponseFormat(ResponseFormat format)
Parameters
Returns
|
Edit this page
View Source
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.
Declaration
public TSelf SetResponseFormat(Type type)
Parameters
| Type |
Name |
Description |
| Type |
type |
|
Returns
|
Edit this page
View Source
SetSafetySettings(List<SafetySetting>)
If set, the model will apply the specified safety settings to filter or moderate the generated content.
Declaration
public TSelf SetSafetySettings(List<SafetySetting> settings)
Parameters
Returns
|
Edit this page
View Source
SetStartingMessage(string)
Sets the starting message or initial prompt for the task. This can be used to provide context or a starting point for the model.
Declaration
public TSelf SetStartingMessage(string startingMessage)
Parameters
| Type |
Name |
Description |
| string |
startingMessage |
|
Returns
|
Edit this page
View Source
SetStopSequences(params string[])
Sets the stop sequences for text generation.
Note: Responses API does not support this parameter.
Declaration
public TSelf SetStopSequences(params string[] stop)
Parameters
| Type |
Name |
Description |
| string[] |
stop |
|
Returns
|
Edit this page
View Source
SetTemperature(Temperature)
Sets the sampling temperature parameter.
Declaration
public TSelf SetTemperature(Temperature temperature)
Parameters
Returns
|
Edit this page
View Source
SetToolChoice(ToolChoice)
Sets the tool choice strategy for the model.
Declaration
public TSelf SetToolChoice(ToolChoice toolChoice)
Parameters
Returns
|
Edit this page
View Source
SetTools(params Tool[])
Sets the tools available for the model to use during generation.
Declaration
public TSelf SetTools(params Tool[] tools)
Parameters
| Type |
Name |
Description |
| Tool[] |
tools |
|
Returns
|
Edit this page
View Source
SetTools(IEnumerable<Tool>)
Sets the tools available for the model to use during generation.
Declaration
public TSelf SetTools(IEnumerable<Tool> tools)
Parameters
Returns
|
Edit this page
View Source
SetTopK(TopK)
Sets the TopK parameter for sampling.
Declaration
public TSelf SetTopK(TopK topK)
Parameters
| Type |
Name |
Description |
| TopK |
topK |
|
Returns
|
Edit this page
View Source
SetTopP(TopP)
Sets the nucleus sampling (TopP) parameter.
Declaration
public TSelf SetTopP(TopP topP)
Parameters
| Type |
Name |
Description |
| TopP |
topP |
|
Returns
|
Edit this page
View Source
SetWebSearchOptions(WebSearchSettings)
Declaration
public TSelf SetWebSearchOptions(WebSearchSettings options)
Parameters
Returns
|
Edit this page
View Source
ValidateRequest()
Validates the request before execution.
Override in derived classes to implement request validation logic.
Declaration
protected override void ValidateRequest()
Overrides
Implements
Extension Methods