Skip to content
pubscout

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.

WASM-ready
$ flutter pub add openai_dart
Source repository

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.

  • firebase_ai

    Choose firebase_ai if your infrastructure uses Google's Firebase AI services instead of OpenAI.

Works with

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