flutter_ai_sdk 1.4.0
flutter_ai_sdk: ^1.4.0 copied to clipboard
A unified wrapper for AI APIs (OpenAI, Anthropic, Google AI, Ollama) with streaming, tool calling, context management, and multimodal support.
Changelog #
All notable changes to Flutter AI SDK are documented here.
1.4.0 - 2026-07-08 #
Prompt caching & universal document input #
- Prompt caching: new
AIConfig.promptCaching(PromptCaching, 5 min or 1 h TTL) — explicitcache_controlon Anthropic; cache hit counters parsed on every provider (Usage.cachedTokens, newUsage.cacheWriteTokens). - Documents:
DocumentContentnow works on every cloud provider — URL sources added on Anthropic, base64fileblocks added on OpenAI (URL passed as a text reference), Google AI unchanged. Support table in the README.
1.3.0 - 2026-07-08 #
Structured outputs & token counting #
- Structured outputs:
ResponseFormat.json(schema: ...)now uses each provider's native guaranteed-schema mechanism — OpenAIjson_schema(with opt-instrictmode), Anthropicoutput_config.format, GeminiresponseJsonSchema, Ollama schema format. - Token counting: new
countTokenson providers andFlutterAI.countTokens({message})on the facade — exact server-side counts on Anthropic (/messages/count_tokens) and Google AI (:countTokens); local estimation elsewhere.
1.2.0 - 2026-07-07 #
Architecture overhaul & new features #
- Architecture: full restructuring into one-class-per-file modules —
config/,models/content/(sealed hierarchy as part files),models/tools/; one folder per provider with a dedicated wire-format mapper; shared streaming loop inBaseProvider(template method); newProviderRegistryfactory supporting custom provider registration. The public API is unchanged. - Tool Runner: automatic agentic tool-calling loop (
ToolRunner,ExecutableTool) — parallel tool execution, error feedback to the model, iteration budget, observability callbacks. - Ollama provider: run local models (Llama, Qwen, Gemma...) with streaming (NDJSON), tools, JSON mode and vision; no API key required.
- Anthropic: consecutive same-role messages are merged, as required by the API's role alternation (fixes parallel tool results).
- Dependencies upgraded for Flutter 3.44.
1.1.0 - 2026-07-06 #
Model refresh #
- Default models updated to current generations:
gpt-5.5,claude-opus-4-8,gemini-3.5-flash. - Model context limits updated (GPT-5.x, Claude 4/5, Gemini 3.x).
- Anthropic provider: never sends
temperatureandtop_ptogether (rejected by Claude 4+); maps therefusalandmodel_context_window_exceededstop reasons. - Providers can receive an injected HTTP client;
FlutterAIaccepts a custom provider. Unit tests for all providers and a CI workflow added. - Dependencies upgraded (
mime2.x,rxdart0.28,flutter_lints6).