chatWithTools

abstract suspend fun chatWithTools(request: ChatRequest, autoExecute: Boolean = true, maxSteps: Int? = null, currentStep: Int = 0, onToolCall: ToolCapable.ToolCallCallback = null, onToolExecutionFailed: ToolCapable.ToolExecutionFailedCallback = null): ChatResponse

Sends a chat request with automatic tool execution.

If autoExecute is true and the model requests tool calls, the client will execute them and continue the conversation until a text response is produced.

Return

The final ChatResponse after all tool calls are resolved.

Parameters

request

The chat request with tools attached.

autoExecute

Whether to automatically execute tool calls (default: true).

onToolCall

Optional callback invoked before each tool execution.


abstract suspend fun chatWithTools(autoExecute: Boolean = true, maxSteps: Int? = null, currentStep: Int = 0, onToolCall: ToolCapable.ToolCallCallback = null, onToolExecutionFailed: ToolCapable.ToolExecutionFailedCallback = null, block: ChatRequestBuilder.() -> Unit): ChatResponse

Sends a chat request with tools using full DSL configuration.

Return

The final ChatResponse after all tool calls are resolved.

Parameters

autoExecute

Whether to automatically execute tool calls (default: true).

onToolCall

Optional callback invoked before each tool execution.

block

A ChatRequestBuilder lambda for configuring the request.