AiBroker class abstract
Base broker — every provider implements this. Capabilities (chat,
embed, translate, image, tts, …) live on separate interfaces in
per-modality folders (lib/src/chat/, lib/src/embed/,
lib/src/translate/, …). Concrete provider classes implement only
the capability interfaces their service actually supports.
Why split? An interface where most methods throw UnsupportedError
pushes runtime errors around for capability checks. The capability
split lets the type system enforce "you can only call embed on
something that's actually an EmbedBroker", which catches misuse at
compile time and makes "what does this provider support?" answerable
by reading the class declaration instead of grepping for throws.
Breaking change in 0.4.0. Pre-0.4, chat / stream / complete
(and, in 0.3.0, chatWithMeta / completeWithMeta) lived on
AiBroker. Now they live on ChatBroker, and embed on
EmbedBroker. Callers either upgrade their variable's declared
type (ChatBroker broker = …) or cast at the call site
((broker as EmbedBroker).embed(…)). AiBrokerRegistry.lookupAs
gives a type-safe lookup that returns null when the broker doesn't
implement the requested capability.
Constructors
- AiBroker()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Stable identifier —
'openai','anthropic','gemini','google_translate', … Used as the key inAiBrokerRegistryand as theKeyResolverlookup id.no setter - label → String
-
Human label for picker UIs.
'OpenAI','Anthropic (Claude)','Google (Gemini)','Google (Translate)'.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
listModels(
String apiKey) → Future< List< String> > - Models suitable for the broker's primary capability, newest first. Returns an empty list for an unset / invalid key, or for providers that have no user-selectable model (e.g. Google Translate v2).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited