openai_realtime_dart
0.2.0, released 2 months ago by langchaindart.dev
Dart client for the OpenAI Realtime API over WebSockets
What it does
Provides a strongly-typed Dart and Flutter client for the OpenAI Realtime API. It communicates over WebSockets, enabling stateful, event-based voice and text interactions.
AI-written summary of version 0.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need direct, lower-level WebSocket session management for the OpenAI Realtime API.
- Your Dart or Flutter application requires real-time voice or text interaction with OpenAI models.
Skip it when
- You prefer using the recommended higher-level openai_dart package for OpenAI APIs.
- You are connecting directly to OpenAI from a browser environment where API keys are at risk, without a relay server.
Strengths
- Strongly-typed interface for OpenAI Realtime API events and actions.
- Built for both server-side Dart and client-side Flutter apps.
- Includes utilities for handling tools, audio streaming, and session updates.
Weaknesses
- Exposes API keys to risk if used directly in a browser environment without a relay server.
- Lower-level alternative compared to the recommended openai_dart package.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 5
Requires Dart 3.12 or later and an OpenAI API key.
final client = RealtimeClient(
apiKey: Platform.environment['OPENAI_API_KEY'],
);
await client.connect();
await client.sendUserMessageContent([
const ContentPart.inputText(text: 'How are you?'),
]);Alternatives
Packages that do the same job and could replace openai_realtime_dart.
- centrifuge
Dart client for real‑time communication with Centrifuge/Centrifugo over WebSockets.
80Compare - angel3_websocket
WebSockets support and event broadcasting for the Angel3 framework.
77Compare - pusher_client_socket
Connect to a Pusher server using WebSockets across all platforms.
52Compare - vmodal_sdk_flutter
Typed VModal API client for Flutter to upload videos and search moments by meaning.
67Compare
Works with
Packages commonly used together with openai_realtime_dart: ones it builds on, ones built on it, and its own family.
- json_annotationopenai_realtime_dart depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- loggingopenai_realtime_dart depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- web_socket_channelopenai_realtime_dart depends on itCross‑platform WebSocket channel wrapper for Dart
- freezed_annotationopenai_realtime_dart depends on itAnnotations for the freezed code-generator.