FunctionTool

@Serializable
class FunctionTool(val name: String, val description: String? = null, val parameters: JsonObject? = null) : ResponseTool

A function the model may call, described by its JSON Schema.

The model answers with a FunctionCallItem; run the function and feed the result back as a FunctionCallOutputItem carrying the same call_id.

Example:

val weather = FunctionTool(
name = "get_weather",
description = "Get the current weather for a city",
parameters = buildJsonObject {
put("type", "object")
putJsonObject("properties") { putJsonObject("city") { put("type", "string") } }
putJsonArray("required") { add("city") }
},
)

Constructors

Link copied to clipboard
constructor(name: String, description: String? = null, parameters: JsonObject? = null)

Properties

Link copied to clipboard

What the function does; helps the model decide when to call it.

Link copied to clipboard

Function name: 1 to 128 characters from [a-zA-Z0-9_-], unique across the tool list.

Link copied to clipboard
val parameters: JsonObject?

JSON-Schema description of the arguments the function accepts.

Link copied to clipboard
open override val type: String

Raw type discriminator of the tool.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String