OpenAiChatClient class

One Chat Completions stream. The client is closed on success, failure, subscription cancellation, timeout, and explicit stop; no shared connection lifetime can accidentally cancel another conversation.

Constructors

OpenAiChatClient({required Uri endpoint, required String model, String? apiKey, Map<String, String> headers = const {}, Map<String, Object?> extraBody = const {}, Duration requestTimeout = const Duration(minutes: 2), int maxEventBytes = 1024 * 1024, int maxResponseBytes = 16 * 1024 * 1024, Client clientFactory()?})

Properties

apiKey String?
final
clientFactory → Client Function()
final
endpoint Uri
Full URL, e.g. https://your-provider.example/v1/chat/completions.
final
extraBody Map<String, Object?>
Provider extensions, e.g. DeepSeek thinking mode or max_tokens. Routing, messages, streaming and tools remain managed by this client.
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
final
maxEventBytes int
final
maxResponseBytes int
final
model String
final
requestTimeout Duration
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stream({required List<Map<String, Object?>> messages, required ChatCancellation cancellation, List<Map<String, Object?>> tools = const []}) Stream<Map<String, Object?>>
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited