flutter_ai_provider_openai 0.1.4
flutter_ai_provider_openai: ^0.1.4 copied to clipboard
OpenAI-compatible LlmProvider for flutter_ai: streams Chat Completions (text, tool calls, finish reasons) as flutter_ai_core AiStreamEvents over an injectable HTTP client.
flutter_ai_provider_openai #
☕ Support this project #
If flutter_ai saves you time, buy me a coffee ☕ — it keeps the whole family maintained.

Streamed responses render through flutter_ai_elements (AiResponse).
An OpenAI-compatible LlmProvider for the flutter_ai family.
Streams the OpenAI Chat Completions API and maps each chunk to
flutter_ai_core AiStreamEvents — text deltas, streamed tool calls, and finish
reasons. Works with the public OpenAI endpoint or any compatible server (Azure
OpenAI, proxies, local servers) via a custom base URL.
Usage #
import 'package:flutter_ai_provider_openai/flutter_ai_provider_openai.dart';
final provider = OpenAiProvider(
apiKey: const String.fromEnvironment('OPENAI_API_KEY'),
defaultModel: 'gpt-4o-mini',
);
// Drive it with flutter_ai_client's UseChatController:
final controller = UseChatController(provider: provider);
controller.sendText('Hello!');
Point it elsewhere with baseUrl:
OpenAiProvider(
apiKey: key,
baseUrl: Uri.parse('https://my-proxy.example.com/v1'),
);
The HTTP client is injectable (client:) for testing or custom transport.
Status #
0.1.0. The request/response mapping is unit-tested against recorded SSE
chunks; it has not been exercised against the live OpenAI API in this release.
Depends on flutter_ai_core via a local path (publish_to: none) until that
package is published.
