flutter_llm_router 1.1.0
flutter_llm_router: ^1.1.0 copied to clipboard
A resilient multi-provider LLM router for Flutter AI Toolkit featuring transparent failover, token cost tracking, and attempt logging.
Changelog #
All notable changes to this project are documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.1.0 - 2026-10-17 #
- Added connectivity-aware failover. When a provider fails with a connection error or timeout,
RouterLlmProvidersilently probes the internet once per request. If the device is offline, it throws the newNoInternetConnectionExceptioninstead of trying every provider. If the device is online, it fails over as before. - Added
ConnectivityCheckerandHttpConnectivityChecker. The default probe ishttps://www.google.com/generate_204with a 3-second timeout, usingHEADon native platforms and ano-corsfetchon web. Configure it throughRouterLlmProvider(connectivityChecker: ...). - Example app: added a "Simulate OpenAI network failure" switch and an offline SnackBar through
LlmChatView.onErrorCallback.
1.0.4 - 2026-10-11 #
- Added screenshots to the pub.dev listing: failover, cost tracking, and quickstart.
1.0.3 - 2026-10-10 #
- Added explicit Windows and Linux (full cross-platform) support declarations in
pubspec.yaml. - Added native Windows (
example/windows/) and Linux (example/linux/) desktop runner scaffolding to enable running the example app natively on both desktop platforms. - Updated
httpdependency constraint to^1.6.0. - Updated documentation with Windows and Linux desktop setup instructions and synchronized dependency version requirements.
1.0.2 - 2026-10-06 #
- Upgraded
flutter_ai_toolkitconstraint to^1.0.0andflutter_lintsto^6.0.0. - Removed discontinued
firebase_vertexaidependency. - Updated
RouterLlmProviderembedding methods and documentation forflutter_ai_toolkit 1.0.0.
1.0.1 - 2026-10-04 #
- Added direct multi-provider configurations for OpenAI, Google Gemini, and Anthropic Claude.
- Refactored example app with MVVM state management (
ChatRouterViewModel). - Added compile-time
--dart-definekey configuration support. - Exported adapters and model types in public library exports.
- Updated repository and issue tracker URLs to open-source-collabs.
1.0.0 - 2026-10-01 #
First release of the local package. It is not published to pub.dev.
Added #
- Package layout for
flutter_llm_router: publiclib/exports,test/,doc/, andexample/, with MIT license and strict analyzer options. ProviderConfigfor a named upstream model, API key, per-token USD prices, optionalbaseUrl, and a 30-second defaulttimeout. IncludescopyWithandcalculateCost.AttemptLogfor one provider try: name, model, timestamp, latency, success, error text, and HTTP status.CostTrackerwithtotalCostNotifier(ValueListenable<double>), token counters,recordUsage,recordCost,reset, anddispose.LlmRouterException,RetryableLlmException,TerminalLlmException, andAllProvidersFailedException.- SSE adapters for OpenAI chat completions, Anthropic
content_block_delta, GeministreamGenerateContent?alt=sse, and OpenRouter chat completions athttps://openrouter.ai/api/v1. HTTP 429, 408, and 5xx, plus timeouts and socket drops, are retryable. HTTP 400, 401, and 403 are terminal. The adapters usepackage:httpand do not importdart:io. RouterLlmProvider, anLlmProviderthat walks providers in order. A retryable failure before the first token fails over. A terminal failure is logged and rethrown. If every provider fails, the router throwsAllProvidersFailedException. Successful streams record estimated token cost.lastAttemptLogsexposes the latest attempt list. Built-in names areopenai,anthropic,gemini, andopenrouter.customAdaptersoverrides that lookup.- Example chat app on
LlmChatViewthat sends one OpenRouter key throughopenai/gpt-4o-mini, thengoogle/gemini-2.5-flash, thenanthropic/claude-haiku-4.5. A switch simulates HTTP 429. The app bar shows live spend, and a sheet lists attempt logs. The example Android manifest allows internet access.
Notes #
- Token counts are
(text.length + 3) ~/ 4, not the provider's billed tokenizer. getDocumentEmbeddingandgetQueryEmbeddingare unimplemented.flutter_ai_toolkit0.5.0 is pinned, andfirebase_vertexaiis constrained to>=1.0.1 <1.5.0because later releases removedTaskType.
