ToolChoice class

Controls how / whether the model selects tools during sampling (spec 2025-11-25 sampling tool calling, SEP-1577).

type is one of auto (model decides), any (must call some tool), none (no tool call), or tool (must call the named tool — name required in that case). Round-trips via toJson / fromJson.

Constructors

ToolChoice({required String type, String? name})
const
ToolChoice.any()
const
ToolChoice.auto()
Convenience constructors mirroring the spec's enumerated modes.
const
ToolChoice.fromJson(Map<String, dynamic> json)
factory
ToolChoice.none()
const
ToolChoice.tool(String toolName)
const

Properties

hashCode int
The hash code for this object.
no setterinherited
name String?
The specific tool name, required when type == tool.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited