OpenAiBroker class

OpenAI chat-completions. Filters listModels to gpt-* / o<digit>* so the picker doesn't show whisper / embeddings / dall-e.

Implemented types

Constructors

OpenAiBroker({Client? client})

Properties

hashCode int
The hash code for this object.
no setterinherited
id String
Stable identifier — 'openai', 'anthropic', 'gemini'. Used as the key in AiBrokerRegistry and as the KeyResolver lookup id.
no setteroverride
label String
Human label for picker UIs. 'OpenAI', 'Anthropic (Claude)', 'Google (Gemini)'.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

chat({required String apiKey, required String model, required ChatRequest request}) Future<String>
Multi-turn. Returns the assistant's raw text for the final turn.
override
complete({required String apiKey, required String model, required String system, required String user, double temperature = 0.3, int maxTokens = 2048}) Future<String>
Single-shot. Returns the assistant's raw text.
override
listModels(String apiKey) Future<List<String>>
Models suitable for chat / completion, newest first. Returns an empty list for an unset / invalid key. Each provider filters out embeddings / vision / audio-only models so the dropdown isn't flooded with irrelevant entries.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stream({required String apiKey, required String model, required ChatRequest request}) Stream<String>
Token-streaming chat. Each event is an incremental delta — concatenating every event yields the same string chat would return. Closes the stream cleanly on end-of-message; errors are surfaced via the stream.
override
toString() String
A string representation of this object.
inherited

Operators

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