Tool class

Something the model can ask to have run.

schema is JSON Schema for the input object — the same shape both the Anthropic and OpenAI-compatible APIs expect.

Constructors

Tool({required String name, required String description, required Map<String, Object?> schema, required Future<String> run(Map<String, Object?> input)})
Creates a tool.
const

Properties

description → String
What the tool does, when to use it, and what it returns. This is the prompt the model reads to decide; vague descriptions are the usual reason a tool is never called.
final
hashCode → int
The hash code for this object.
no setterinherited
name → String
Name the model calls. Keep it short and specific.
final
run → Future<String> Function(Map<String, Object?> input)
Runs the tool. Whatever it returns is given back to the model verbatim, so return text the model can read. Throwing is fine: the failure is reported to the model, which can try something else.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schema → Map<String, Object?>
JSON Schema of the input object.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toAnthropicJson() → Map<String, Object?>
The Anthropic Messages API form.
toOpenAIJson() → Map<String, Object?>
The OpenAI-compatible form.
toString() → String
A string representation of this object.
inherited

Operators

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