Skip to content
pubscout

openai_realtime_dart

0.2.0, released 2 months ago by langchaindart.dev

Dart client for the OpenAI Realtime API over WebSockets

WASM-ready
$ flutter pub add openai_realtime_dart
Source repository

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.

Works with

Packages commonly used together with openai_realtime_dart: ones it builds on, ones built on it, and its own family.