Skip to main content

flutter_llm_router 1.1.0 copy "flutter_llm_router: ^1.1.0" to clipboard
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, RouterLlmProvider silently probes the internet once per request. If the device is offline, it throws the new NoInternetConnectionException instead of trying every provider. If the device is online, it fails over as before.
  • Added ConnectivityChecker and HttpConnectivityChecker. The default probe is https://www.google.com/generate_204 with a 3-second timeout, using HEAD on native platforms and a no-cors fetch on web. Configure it through RouterLlmProvider(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 http dependency 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_toolkit constraint to ^1.0.0 and flutter_lints to ^6.0.0.
  • Removed discontinued firebase_vertexai dependency.
  • Updated RouterLlmProvider embedding methods and documentation for flutter_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-define key 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: public lib/ exports, test/, doc/, and example/, with MIT license and strict analyzer options.
  • ProviderConfig for a named upstream model, API key, per-token USD prices, optional baseUrl, and a 30-second default timeout. Includes copyWith and calculateCost.
  • AttemptLog for one provider try: name, model, timestamp, latency, success, error text, and HTTP status.
  • CostTracker with totalCostNotifier (ValueListenable<double>), token counters, recordUsage, recordCost, reset, and dispose.
  • LlmRouterException, RetryableLlmException, TerminalLlmException, and AllProvidersFailedException.
  • SSE adapters for OpenAI chat completions, Anthropic content_block_delta, Gemini streamGenerateContent?alt=sse, and OpenRouter chat completions at https://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 use package:http and do not import dart:io.
  • RouterLlmProvider, an LlmProvider that 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 throws AllProvidersFailedException. Successful streams record estimated token cost. lastAttemptLogs exposes the latest attempt list. Built-in names are openai, anthropic, gemini, and openrouter. customAdapters overrides that lookup.
  • Example chat app on LlmChatView that sends one OpenRouter key through openai/gpt-4o-mini, then google/gemini-2.5-flash, then anthropic/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.
  • getDocumentEmbedding and getQueryEmbedding are unimplemented.
  • flutter_ai_toolkit 0.5.0 is pinned, and firebase_vertexai is constrained to >=1.0.1 <1.5.0 because later releases removed TaskType.
5
likes
150
points
681
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A resilient multi-provider LLM router for Flutter AI Toolkit featuring transparent failover, token cost tracking, and attempt logging.

Repository (GitHub)
View/report issues

Topics

#ai #llm #flutter-ai-toolkit #cost-tracking #failover

License

MIT (license)

Dependencies

flutter, flutter_ai_toolkit, http

More

Packages that depend on flutter_llm_router