ToolCall

@SerialName(value = "tool_call")
@Serializable
data class ToolCall(val id: String, val name: String, val argumentsJson: String) : Content.Response, Content.Request

A tool invocation requested by the model.

Contains the tool's unique id, name, and serialized argumentsJson. Implements both Response (received from model) and Request (can be forwarded back as an assistant message).

Samples

// ToolCall and ToolResult are used as a request only if you have disabled autoExecute and are processing the tool manually.
val executeResult = executeTool(toolCall.name, toolCall.argumentsJson) // Returns String.

// Create a ToolResult.
val toolResult = Content.ToolResult(
    toolCallId = toolCall.id,
    name = toolCall.name,
    content = toolCall.argumentsJson
)

// Send toolResult to API...

Constructors

Link copied to clipboard
constructor(id: String, name: String, argumentsJson: String)

Properties

Link copied to clipboard

JSON-serialized arguments for the tool.

Link copied to clipboard
val id: String

Unique identifier for this tool call.

Link copied to clipboard

The name of the tool to execute.

Functions

Link copied to clipboard

Wraps this request content as an assistant Message.

Link copied to clipboard

Attempts to cast this response content to a request-compatible content type.

Link copied to clipboard