dart_openai
8.0.0, released 3 months ago by gwhyyy.com
Unofficial Dart and Flutter SDK for the OpenAI API and compatible providers.
What it does
Provides typed clients for OpenAI and compatible APIs like DeepSeek, Ollama, and LM Studio. It supports chat completions, streaming, vector stores, fine-tuning, images, audio, and more across all platforms including web.
AI-written summary of version 8.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to integrate OpenAI or compatible LLM APIs into your Dart or Flutter app.
- You require multi-platform support including Flutter Web.
- You need robust streaming, automatic retries, and rate-limit tracking.
Skip it when
- You are building exclusively with official first-party SDKs that have guaranteed OpenAI synchronization.
- You require only on-device models without any remote API connectivity.
Strengths
- Comprehensive API coverage including Responses, Chat, Realtime, Batch, and Vector Stores.
- Per-client configuration allows multiple accounts or local models to run side-by-side.
- Platform-neutral file handling supports web and native disk access.
Weaknesses
- It is an unofficial SDK, meaning it might lag behind official OpenAI API updates.
- Relies on community maintenance.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
Add dependency to pubspec.yaml and configure your OpenAI API key or compatible endpoint URL.
import 'package:dart_openai/dart_openai.dart';
Future<void> main() async {
final client = OpenAIClient(apiKey: 'sk-...');
final completion = await client.chat.create(
model: 'gpt-4o',
messages: [
const OpenAIChatCompletionChoiceMessageModel(
role: OpenAIChatMessageRole.user,
content: 'Say hello in five words.',
),
],
);
print(completion.choices.first.message.content);
}Alternatives
Packages that do the same job and could replace dart_openai.
- ollama_dart
Pick it if you are specifically targeting Ollama local models and want an Ollama-focused client.
88Compare - openai_dart
Alternative Dart client for the OpenAI API.
91Compare - llamadart
Pick it if you want to run Llama models directly on-device rather than calling a remote API.
93Compare
Works with
Packages commonly used together with dart_openai: ones it builds on, ones built on it, and its own family.
- http_parserdart_openai depends on itA platform-independent package for parsing and serializing HTTP formats.
- fetch_clientdart_openai depends on itHTTP client using Fetch API with WASM support, cancelable and streamable requests
- intl_messagesBuilt on dart_openaiMessage internationalization and localization framework with OpenAI translation tools integration.
- arb_translateBuilt on dart_openaiCLI tool to automatically generate missing translations for ARB files using AI models.