flutter_ai_sdk 1.9.0
flutter_ai_sdk: ^1.9.0 copied to clipboard
A unified wrapper for AI APIs (OpenAI, Anthropic, Google AI, Ollama, Mistral, xAI, DeepSeek, OpenRouter) with streaming, tool calling, context management, and multimodal support.
Changelog #
All notable changes to Flutter AI SDK are documented here.
1.9.0 - 2026-07-27 #
Batch processing #
FlutterAI.submitBatch/getBatchStatus/getBatchResults/waitForBatchCompletion: new facade methods for asynchronous batch processing at ~50% lower cost, backed by a newBatchProviderinterface (kept separate fromBaseProvider— only Anthropic and OpenAI have a batch API). ThrowsAIFeatureNotSupportedErrorwhere unsupported.- Anthropic:
POST /v1/messages/batches, pollsprocessing_status, parses the JSONL results file. - OpenAI: uploads a JSONL input file (
purpose=batch), creates the batch job, pollsstatus, downloads and parses the JSONL output file. - New
BatchRequest/BatchJob/BatchResultmodels and apollBatchJobhelper (exponential backoff, capped) shared by both providers. - Batch results are not guaranteed to come back in submission order —
always match by
BatchRequest.customId/BatchResult.customId. - New
AIHttpClient.postMultipartfor file uploads.
1.8.0 - 2026-07-27 #
Embeddings #
FlutterAI.embed/embedBatch: new facade methods generating embedding vectors, backed by a newEmbeddingProviderinterface (deliberately separate fromBaseProvider— not every chat provider has an embeddings API). ThrowsAIFeatureNotSupportedErroron providers that don't implement it (Anthropic, xAI, DeepSeek, OpenRouter).- Implemented on OpenAI (
text-embedding-3-small), Google AI (gemini-embedding-001, viabatchEmbedContents), Ollama (embeddinggemma, local, no API key) and Mistral (mistral-embed, reusing the shared OpenAI-compatible wire format). - New
EmbeddingRequest/EmbeddingResponsemodels and acosineSimilarityutility for comparing vectors.
1.7.0 - 2026-07-27 #
Thinking / reasoning output #
ThinkingContent: new content type surfacing the model's intermediate reasoning, plusAIResponse.thinking/hasThinkingandMessage.hasThinkingconvenience accessors.AIConfig.thinking(ThinkingConfig, optionalThinkingEffort) opts in per-provider:- Anthropic: adaptive extended thinking (
thinking: {type: "adaptive"}), effort mapped tooutput_config.effort. - Google AI:
generationConfig.thinkingConfig(includeThoughts,thinkingLevel). - DeepSeek:
thinking: {type: "enabled"};reasoning_contentparsed intoThinkingContenton any OpenAI-compatible provider that returns it, not just DeepSeek. - Other providers ignore the configuration.
- Anthropic: adaptive extended thinking (
- Streaming: new
StreamChunk.thinkingDelta/isThinkingDelta, kept separate from regular text deltas so accumulation logic isn't polluted. - Thinking output is informational only — it isn't replayed back to the model on later turns.
1.6.0 - 2026-07-27 #
More providers #
- New providers: Mistral AI, xAI (Grok), DeepSeek and OpenRouter — all
expose an OpenAI-compatible chat completions API, so they're implemented
as thin subclasses of a new
OpenAICompatibleProviderbase that reuses the existing OpenAI wire-format mapper unchanged. AIResponse.provideron these new providers is correctly tagged (the shared mapper'sparseResponsenow accepts the calling provider instead of always defaulting toAIProvider.openai).- DeepSeek has no
/v1segment in its base URL (https://api.deepseek.com), unlike the other three.
1.5.0 - 2026-07-11 #
Conversation persistence #
Memory: wired up the (previously dormant, unused since v1.0.0)Memory/InMemoryMemory/LimitedMemoryclasses toContextManagerandFlutterAI—attachMemory/detachMemoryfor automatic background saves,saveConversation/loadConversationfor one-shot save/restore.JsonFileMemory: new file-based implementation (one JSON file per conversation); resolves to a stub throwingUnsupportedErroron the web, wheredart:iois unavailable. No new dependency in the main package.ConversationSummary: lightweight metadata viaMemory.listSummariesfor building a conversation-list UI without loading full histories.- Split
context/memory.dartinto acontext/persistence/module (one class per file), matching the rest of the codebase. - Fixed
Conversation/MessageJSON round-tripping:updatedAtwas dropped onConversation.fromJson; audio and document content silently turned into empty text on deserialization; base64 images lost theirdetaillevel and were mis-parsed as URLs.
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).