flutter_ai_tools

Provider-neutral tool calling for flutter_ai — declare a ToolSpec, register it, and let the agent loop run it. Pure Dart, with a web-search adapter included.

Tool calls flowing through the agent loop

flutter_ai_tools on pub.dev pub points License: BSD-3-Clause

Family: flutter_ai · core · client · elements · mcp · voice
Recipes · Migrating from the Vercel AI SDK


Provider-neutral tool calling for the flutter_ai family. Pure Dart, no Flutter dependency.

What it does

  • ToolSpec — declare a tool (name, description, JSON-Schema parameters) and an optional client-side executor.
  • ToolRegistry — collect tools, hand their definitions to a provider, and run a ToolCallPart into a ToolResultPart. Unknown tools and thrown executors become error results, never crashes.
  • Web searchwebSearchTool(adapter) turns any WebSearchAdapter (Tavily, Brave, SerpAPI, custom) into a callable tool returning SearchResults.

Usage

final tools = ToolRegistry([
  ToolSpec(
    name: 'get_weather',
    description: 'Get the weather for a city',
    parametersSchema: const {
      'type': 'object',
      'properties': {'city': {'type': 'string'}},
      'required': ['city'],
    },
    execute: (args) => weatherApi.fetch(args['city']! as String),
  ),
]);

// Advertise to a provider:
controller.setTools(tools.definitions);

// Fulfill a call the model made:
final result = await tools.run(toolCallPart); // -> ToolResultPart
final tools = ToolRegistry([webSearchTool(MyTavilyAdapter())]);
class MyTavilyAdapter implements WebSearchAdapter {
  @override
  Future<List<SearchResult>> search(String query, {int? maxResults}) async {
    // call your search backend, map hits into SearchResult
  }
}

Status

Published on pub.dev (see the CHANGELOG); depends on flutter_ai_core. See example/.

☕ Support this project

Buy me a coffee on Ko-fi

If flutter_ai saves you time, buy me a coffee ☕ — it keeps the whole family maintained.

Libraries

flutter_ai_tools
Provider-neutral tool calling for the flutter_ai family.