AiTool class final

A tool the model can invoke — the unit of AI agency.

AiTool(
  name: 'get_weather',
  description: 'Get current weather for a city',
  parametersSchema: {
    'type': 'object',
    'properties': {
      'city': {'type': 'string'},
    },
    'required': ['city'],
  },
  execute: (args) async => 'Sunny, 25°C',
)

Constructors

AiTool({required String name, required String description, required Future<Object?> execute(Map<String, Object?> arguments), Map<String, Object?> parametersSchema = const {'type' : 'object', 'properties' : {}}})
const

Properties

description → String
Natural-language description the model uses to decide when to call it.
final
execute → Future<Object?> Function(Map<String, Object?> arguments)
Executes the tool with parsed arguments and returns the string result the model should see. Non-string returns are JSON-encoded automatically.
final
hashCode → int
The hash code for this object.
no setterinherited
name → String
Tool name the model references (snake_case, e.g. get_weather).
final
parametersSchema → Map<String, Object?>
JSON Schema describing the arguments object.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runFromJson(String argumentsJson) → Future<String>
Runs the tool with raw JSON arguments (from the model) and returns the string result.
toRequestJson() → Map<String, Object?>
The OpenAI tool declaration shape.
toString() → String
A string representation of this object.
inherited

Operators

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