Class ChatRequest
- Namespace
- OllamaSharp.Models.Chat
- Assembly
- OllamaSharp.dll
Represents a request to generate a chat completion using the specified model and parameters.
public class ChatRequest : OllamaRequest
- Inheritance
-
ChatRequest
- Inherited Members
Properties
Format
Gets or sets the format to return a response in. Currently accepts "json" or JsonSchema or null.
[JsonPropertyName("format")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object? Format { get; set; }
Property Value
KeepAlive
Gets or sets the KeepAlive property, which decides how long a given model should stay loaded.
[JsonPropertyName("keep_alive")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? KeepAlive { get; set; }
Property Value
Messages
Gets or sets the messages of the chat, this can be used to keep a chat memory.
[JsonPropertyName("messages")]
public IEnumerable<Message>? Messages { get; set; }
Property Value
Model
Gets or sets the model name (required).
[JsonPropertyName("model")]
public string Model { get; set; }
Property Value
Options
Gets or sets additional model parameters listed in the documentation for the Modelfile such as temperature.
[JsonPropertyName("options")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public RequestOptions? Options { get; set; }
Property Value
Stream
Gets or sets a value indicating whether the response will be returned as a single response object rather than a stream of objects.
[JsonPropertyName("stream")]
public bool Stream { get; set; }
Property Value
Template
Gets or sets the full prompt or prompt template (overrides what is defined in the Modelfile).
[JsonPropertyName("template")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Template { get; set; }
Property Value
Think
Gets or sets a value to enable or disable thinking. Use reasoning models like openthinker, qwen3, deepseek-r1, phi4-reasoning that support thinking when activating this option. This might cause errors with non-reasoning models, see https://github.com/awaescher/OllamaSharp/releases/tag/5.2.0 More information: https://github.com/ollama/ollama/releases/tag/v0.9.0
[JsonPropertyName("think")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ThinkValue? Think { get; set; }
Property Value
Tools
Gets or sets the tools for the model to use if supported. Requires stream to be set to false.
[JsonPropertyName("tools")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IEnumerable<object>? Tools { get; set; }