ChatRequest

@Serializable
data class ChatRequest(val chat: Chat, val choicesCount: Int? = null, val temperature: Double? = null, val maxTokens: Int? = null, val topK: Int? = null, val topP: Double? = null, val reasoning: ReasoningConfig? = null, val tools: List<ChatTool> = emptyList(), stream: Boolean = false)

A fully-formed request wrapping a Chat with optional generation parameters and tools.

Create instances via io.kory.core.dsl.chat.request.koryChatRequest or Chat.asChatRequest.

Parameters

choicesCount

Number of response choices to generate.

topP

Nucleus sampling parameter (0.0–1.0). null uses provider default.

See also

Samples

// For create a chat request using koryChatRequest dsl function.
val chatRequest = koryChatRequest {
    temperature = 0.7
    maxTokens = 4096
    topK = 40
    reasoning = ReasoningConfig.Enabled(ReasoningConfig.Level.LOW)
    // The “chat” function refers to the chat that will be used in the request.
    chat(
        model = "gpt-5.6-sol",
    ) {
        // Body for messages.
        user("Ping!")
    }
}
// Create chat using default Chat constructor or koryChat dsl function.
val chat = koryChat(
    model = "gpt-5.6-sol"
) {
    user("Ping!")
}

val chatRequest = ChatRequest(
    chat = chat,
    temperature = 0.7,
    maxTokens = 4096,
    topK = 40,
    reasoning = ReasoningConfig.Enabled(ReasoningConfig.Level.LOW),
    tools = emptyList()
)

Constructors

Link copied to clipboard
constructor(chat: Chat, choicesCount: Int? = null, temperature: Double? = null, maxTokens: Int? = null, topK: Int? = null, topP: Double? = null, reasoning: ReasoningConfig? = null, tools: List<ChatTool> = emptyList(), stream: Boolean = false)

Properties

Link copied to clipboard
val chat: Chat

The conversation containing messages and model name.

Link copied to clipboard
Link copied to clipboard

Maximum tokens to generate. null uses provider default.

Link copied to clipboard

Reasoning/thinking configuration. null disables reasoning.

Link copied to clipboard

Sampling temperature (0.0–2.0). null uses provider default.

Link copied to clipboard
@Transient
val tools: List<ChatTool>

List of KoryTool instances available to the model. Not serialized.

Link copied to clipboard
val topK: Int?

Top-K sampling parameter. null uses provider default.

Link copied to clipboard
val topP: Double?