Type-safe Dart clients for OpenAI, Anthropic, Google Gemini, Mistral, Ollama, and more — all sharing a consistent API shape. Built for Flutter apps, backends, CLIs, and server-side Dart across every platform.
Table of Contents
The AI provider clients share a consistent shape — pick one and start with a few lines:
OpenAI
dependencies:
openai_dart: ^3.0.0import 'package:openai_dart/openai_dart.dart';
Future<void> main() async {
final client = OpenAIClient.fromEnvironment();
try {
final response = await client.responses.create(
CreateResponseRequest(
model: 'gpt-5.4',
input: ResponseInput.text('What is the capital of France?'),
),
);
print(response.outputText);
} finally {
client.close();
}
}Anthropic
dependencies:
anthropic_sdk_dart: ^1.4.0import 'package:anthropic_sdk_dart/anthropic_sdk_dart.dart';
Future<void> main() async {
final client = AnthropicClient.fromEnvironment();
try {
final response = await client.messages.create(
MessageCreateRequest(
model: 'claude-sonnet-4-6',
maxTokens: 1024,
messages: [InputMessage.user('What is the capital of France?')],
),
);
print(response.text);
} finally {
client.close();
}
}Google Gemini
dependencies:
googleai_dart: ^4.0.0import 'package:googleai_dart/googleai_dart.dart';
Future<void> main() async {
final client = GoogleAIClient.fromEnvironment();
try {
final response = await client.models.generateContent(
model: 'gemini-2.5-flash',
request: GenerateContentRequest(
contents: [Content.text('Explain why Dart works well for APIs.')],
),
);
print(response.text);
} finally {
client.close();
}
}Ollama
dependencies:
ollama_dart: ^2.0.0import 'package:ollama_dart/ollama_dart.dart';
Future<void> main() async {
final client = OllamaClient();
try {
final response = await client.chat.create(
request: ChatRequest(
model: 'gpt-oss',
messages: [ChatMessage.user('Explain what Dart isolates do.')],
),
);
print(response.message?.content);
} finally {
client.close();
}
}| Package | Description | Version | Downloads |
|---|---|---|---|
| openai_dart | OpenAI — Responses, Chat Completions, images, audio, realtime | ||
| anthropic_sdk_dart | Anthropic — Claude messages, streaming, tools, extended thinking | ||
| googleai_dart | Google AI / Vertex AI — Gemini generation, embeddings, Live API | ||
| mistralai_dart | Mistral AI — chat, embeddings, OCR, TTS, reasoning, agents | ||
| ollama_dart | Ollama — local chat, streaming, embeddings, tool calling | ||
| open_responses | OpenResponses — one typed interface, multiple providers | ||
| chromadb | ChromaDB — vector search, collections, multi-tenant RAG | ||
| openai_realtime_dart | OpenAI Realtime — lower-level WebSocket sessions | ||
| tavily_dart | Tavily — web search and research for agents and RAG |
- Pure Dart — works everywhere: Flutter apps, backends, CLIs, and server-side Dart across iOS, Android, macOS, Windows, Linux, and Web.
- Type-safe — sealed classes, typed request/response models, and ergonomic helpers.
- Consistent shape — AI provider clients share
fromEnvironment()for config, similar resource methods, andclose()for cleanup. - Minimal dependencies — just
http,logging,meta, and where neededweb_socket. - Strict semver — follows semver.org so downstream packages can depend on stable, predictable version ranges.
These open-source packages and apps use one or more clients from this repo. For more, see the GitHub dependents graph.
| Package | Downloads |
|---|---|
| langchain_dart | |
| dartantic | |
| genkit-dart |
| App | Stars |
|---|---|
| Anx Reader | |
| ApiDash | |
| Lotti |
Use llms.txt for package hubs, llms-ctx.txt for the non-optional concatenated context bundle, and llms-ctx-full.txt for the full bundle including optional sources.
If these packages are useful to you or your company, please consider sponsoring the project. Development and maintenance are provided to the community for free, but integration tests against real APIs and the tooling required to build and verify releases still have real costs. Your support, at any level, helps keep these packages maintained and free for the Dart & Flutter community.
AI Clients Dart is licensed under the MIT License.