anasfik/openai

The unofficial OpenAI SDK for Dart & Flutter. Full API coverage + OpenAI-compatible providers (Azure, DeepSeek, LM Studio, Ollama): Responses, Chat, Realtime, Videos, Batch, Fine-tuning.

What it solves

It provides a comprehensive, typed SDK for Dart and Flutter developers to integrate OpenAI's API and other OpenAI-compatible providers (like DeepSeek, Ollama, and Groq) into their applications without writing raw HTTP requests.

How it works

The library acts as a wrapper around the OpenAI wire format, offering typed clients for various API surfaces including chat completions, audio, images, and fine-tuning. It supports both a global facade for simple setups and individual OpenAIClient instances for managing multiple accounts or providers. It includes a built-in SSE engine for streaming responses and an automatic retry mechanism with exponential backoff for transient failures.

Who it’s for

Dart and Flutter developers building AI-powered apps across Android, iOS, macOS, Linux, Windows, web, and server-side Dart.

Highlights

  • Broad API Coverage: Supports almost all major OpenAI surfaces including Realtime, Vector Stores, Evals, and Administration.
  • Cross-Platform File Handling: Uses a platform-neutral file type to ensure file uploads work seamlessly on both native and web platforms.
  • Provider Agnostic: Compatible with any service that implements the OpenAI API format, including Azure OpenAI and local LLMs via LM Studio or Ollama.
  • Resilient Networking: Features automatic retries for transient errors and an idle watchdog for streaming connections to prevent hanging.
  • Strongly Typed: Provides typed exceptions and models for all request and response payloads.

Related

  • Project
  • Project
  • Project
  • Project
  • Project