One unified API for Gemini, OpenAI, Anthropic, HuggingFace, Ollama, on-device Gemma, and GGUF models — with tool calling, memory, and safety guardrails built in.
The Problem
Building AI agents in Flutter is fragmented. Every provider has a different API shape. There's no standard way to switch between cloud and on-device inference. Tool calling, persistent memory, and safety guardrails are always custom implementations.
The result: developers rebuild the same plumbing for every project.
What It Is
genesis_ai_sdk is a universal Flutter SDK for building AI agents that run locally and in the cloud. One clean API. Seven providers. Zero vendor lock-in.
Supports:
- Gemini (Google)
- OpenAI (GPT-4o)
- Anthropic (Claude)
- HuggingFace (any public model, no download needed)
- Ollama (local server, no API key)
- On-device Gemma (fully offline)
- On-device GGUF via llama.cpp (fully offline)
Switch providers by changing one line. Your agent code stays the same.
Quick Start — 10 Lines of Code
import 'package:genesis_ai_sdk/genesis_ai_sdk.dart';
final agent = GenesisAgent(
provider: GeminiProvider(apiKey: 'YOUR_KEY'),
systemPrompt: 'You are a helpful assistant.',
tools: [GenesisTools.calculator, GenesisTools.dateTime],
);
final response = await agent.chat('What is 1337 * 42, and what day is it?');
print(response);
The agent figures out which tool to call, executes it, and returns the answer. No prompt engineering needed.
The Features That Actually Matter
Real Tool Calling — Not Just Text
The ReAct loop is fully implemented. The agent reasons → calls tools → observes results → repeats until it has a complete answer. An onStep callback fires for every intermediate step — perfect for building a "thinking…" UI.
Custom tools are five lines:
final weatherTool = GenesisTool.define(
name: 'get_weather',
description: 'Returns weather for a city.',
params: {'city': ToolParam.string(description: 'City name')},
execute: (args) async => fetchWeather(args['city']),
);
Any HuggingFace Model — No Download
final agent = GenesisHub.fromHFCloud(
modelId: 'Qwen/Qwen2.5-0.5B-Instruct',
apiToken: 'hf_xxxx',
);
final reply = await agent.chat('Explain transformers in one sentence.');
The HF Inference Router supports virtually all public HuggingFace models via multiple GPU backends (featherless, nebius, together, sambanova). No model download, no conversion, no GPU on your end. Free tier available with any HF account.
Fully Offline — On-Device Models
For privacy-sensitive apps or zero-connectivity scenarios, run everything on-device.
For Gemma (Android, iOS, macOS, Windows):
final provider = GemmaProvider(
modelId: 'gemma-3-1b-it',
modelPath: await GenesisHubPlatformPaths.platformModelsDir(),
);
For GGUF via llama.cpp (Android, macOS, Windows, Linux):
final provider = LlamaCppProvider(modelPath: '/path/to/model.gguf');
platformModelsDir() returns the correct writable path on every platform automatically — no more hardcoded paths that break on Android.
Memory That Survives App Restarts
For in-process memory (current session only):
memory: InMemoryStore()
For persistent memory that survives app restarts (backed by Hive):
memory: HiveMemoryStore(sessionId: 'user_${userId}')
Safety Layer Built In
Block prompt injection before it reaches the model:
final clean = InputGuard.withInjectionDetection().validate(userInput);
Redact PII from model responses (emails, phones, credit cards):
final safe = OutputGuard.withPiiRedaction().process(rawOutput);
Rate limiting per user:
RateLimiter(maxRequests: 20, windowDuration: Duration(minutes: 1)).check(userId);
Smart Routing and Fallback
Automatic fallback if the primary provider fails:
final router = SmartRouter(
primary: GeminiProvider(apiKey: '...'),
secondary: OllamaProvider(model: 'llama3.2'),
);
Privacy-first routing — anonymise sensitive fields before they leave the device:
final router = PrivacyRouter(
cloudProvider: OpenAIProvider(apiKey: '...'),
sensitiveKeys: ['email', 'phone', 'ssn'],
);
The GenesisHub — One Line for Everything
From HuggingFace cloud (no download):
GenesisHub.fromHFCloud(modelId: 'Qwen/Qwen2.5-0.5B-Instruct', apiToken: '...')
From a local model file (auto-detects .gguf / .litertlm / .task):
GenesisHub.fromFile('/path/to/model.gguf')
From Ollama:
await GenesisHub.fromOllama(model: 'llama3.2')
From HuggingFace with auto-download:
await GenesisHub.fromHuggingFace(repoId: 'litert-community/Qwen3-0.6B', filename: 'model.litertlm', destinationDir: dir)
Platform Support
| Platform | Cloud | Ollama | Gemma | GGUF |
|---|---|---|---|---|
| Android | ✅ | ✅ | ✅ | ✅ |
| iOS | ✅ | ✅ | ✅ | ⚠️ (xcframework needed) |
| macOS | ✅ | ✅ | ✅ | ✅ |
| Windows | ✅ | ✅ | ✅ | ✅ |
| Web | ✅ | ❌ | ❌ | ❌ |
| Linux | ✅ | ✅ | ❌ | ✅ |
Installation
Add to your pubspec.yaml:
dependencies:
genesis_ai_sdk: ^0.1.0
Then run:
flutter pub get
What's Next
This is v0.1.1. On the roadmap:
- genesis_ai_ui — Flutter UI components that render dynamically based on AI responses
- genesis_ai_tools — real-world device tools: camera, location, contacts, clipboard
- Semantic memory with vector search
- Mistral, Groq, Cohere providers
Links
- pub.dev: https://pub.dev/packages/genesis_ai_sdk
- GitHub: https://github.com/Devanshv17/genesis_ai_sdk
If this saved you time, a star on GitHub or a like on pub.dev helps more people find it.

Top comments (1)
This looks like a handy toolkit for integrating AI into Flutter apps! Have you had any experience with performance differences between the cloud-based models and on-device Gemma?