flutter_ai_provider_openai 0.1.10
flutter_ai_provider_openai: ^0.1.10 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
OpenAI streaming provider for flutter_ai — Chat Completions mapped to AiStreamEvents. Works with the public API or any compatible endpoint (Azure, proxies, local servers).
Family: flutter_ai ·
core · client · elements ·
anthropic · gemini
Recipes · Migrating from the Vercel AI SDK
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 #
Published on pub.dev (see the CHANGELOG); depends on flutter_ai_core. The
request/response mapping is unit-tested against recorded SSE chunks.
☕ Support this project #
If flutter_ai saves you time, buy me a coffee ☕ — it keeps the whole family maintained.
