openai_dart
13.0.0, released 2 days ago by davidmiguel.com
Dart and Flutter client for OpenAI REST APIs and realtime WebSocket/WebRTC workflows.
What it does
Provides type-safe access to OpenAI APIs including GPT, image and audio generation, embeddings, and realtime workflows. Supports Dart and Flutter across mobile, desktop, web, and servers.
AI-written summary of version 13.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to integrate OpenAI text generation, tool calling, or structured outputs in a Dart or Flutter app.
- You want real-time audio or WebSocket workflows connected to OpenAI models.
Skip it when
- You require on-device local models without external API calls.
- You are using the deprecated Assistants API which shut down on August 26, 2026.
Strengths
- Comprehensive API coverage including Responses API, images, audio, agents, and realtime sessions.
- Works in both pure Dart backends and Flutter apps without Flutter-specific dependencies.
Weaknesses
- Requires managing API keys and keeping sensitive keys secure on trusted infrastructure rather than client-side apps.
- Relies entirely on remote network calls and third-party service availability.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 6
Requires Dart 3.12 or later and an OPENAI_API_KEY environment variable or explicit configuration.
import 'package:openai_dart/openai_dart.dart';
Future<void> main() async {
final client = OpenAIClient.fromEnvironment();
try {
final response = await client.responses.create(
const CreateResponseRequest(
model: 'gpt-6.2-sol',
input: ResponseInput.text('What is the capital of France?'),
),
);
print(response.outputText);
} finally {
client.close();
}
}Alternatives
Packages that do the same job and could replace openai_dart.
- llamadart
Choose llamadart if you need to run local language models rather than communicating with the remote OpenAI REST API.
93Compare - firebase_ai
Choose firebase_ai if your infrastructure uses Google's Firebase AI services instead of OpenAI.
86Compare
Works with
Packages commonly used together with openai_dart: ones it builds on, ones built on it, and its own family.
- cryptoopenai_dart depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- http_parseropenai_dart depends on itA platform-independent package for parsing and serializing HTTP formats.
- loggingopenai_dart depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- web_socketopenai_dart depends on itAn easy-to-use library for communicating with WebSockets that has multiple implementations.
- dartantic_aiBuilt on openai_dartAgent framework for building client and server-side apps in Dart with generative AI.
- langchain_openaiBuilt on openai_dartLangChain.dart integration module for OpenAI APIs.