Class CompletionRequest
Legacy completion request for models that do not support chat-based interactions.
public class CompletionRequest : IJsonRequest
- Inheritance
-
objectCompletionRequest
Properties
FrequencyPenalty
Optional. Positive values penalize new tokens based on their existing frequency in the text so far,
decreasing the model's likelihood to repeat the same line verbatim.
Range: -2.0–2.0
public FrequencyPenalty FrequencyPenalty { get; set; }
Property Value
Instructions
Optional. The system message to use for the model.
public string Instructions { get; set; }
Property Value
- string
MaxTokens
Optional. The maximum number of tokens to generate in the completion.
public int? MaxTokens { get; set; }
Property Value
- int?
Model
The AI model to use for the request.
public string Model { get; set; }
Property Value
- string
N
The number of responses to generate. Defaults to 1.
public int? N { get; set; }
Property Value
- int?
Prompt
The text prompt to complete.
Required for:
- OpenAI legacy models
- OpenRouter completion requests
public string Prompt { get; set; }
Property Value
- string
ResponseFormat
Optional. An object specifying the format that the model must output.
Setting to { "type": "json_schema", "json_schema": { ...} }
enables Structured Outputs which ensures the model will match your supplied JSON schema.Learn more in the Structured Outputs guide.
Setting to { "type": "json_object" } enables the older JSON mode, which ensures the message the model generates is valid JSON.Using json_schema is preferred for models that support it.
public ResponseFormat ResponseFormat { get; set; }
Property Value
Seed
Optional. Random seed for reproducibility. Set to the same value for deterministic output.
public uint? Seed { get; set; }
Property Value
- uint?
Stop
Optional. List of strings that, if generated, will stop further generation.
public List<string> Stop { get; set; }
Property Value
- List<string>
Stream
Optional. Enable streaming of results.
Defaults to false
public bool? Stream { get; set; }
Property Value
- bool?
StreamOptions
Optional. Whether to include usage information in the response
public StreamOptions StreamOptions { get; set; }
Property Value
Temperature
Optional. Sampling temperature: controls randomness in output.
- Lower = deterministic
- Higher = creative
public Temperature Temperature { get; set; }