AiBroker class abstract

Vendor-neutral AI broker. One implementation per provider (Claude, OpenAI, Gemini). Callers depend on this interface; the AiBrokerRegistry is the indirection that lets the active provider change at runtime.

API keys arrive per-call. Storage is the caller's problem — either pass them directly (Flutter apps that already own a SecureStore) or resolve them through a KeyResolver (CLI / backend).

Constructors

AiBroker()

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 setter
label String
Human label for picker UIs. 'OpenAI', 'Anthropic (Claude)', 'Google (Gemini)'.
no setter
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.
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.
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.
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.
toString() String
A string representation of this object.
inherited

Operators

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