AnthropicBroker class
Anthropic Claude (/v1/messages). system is a top-level field,
not a role — keep it out of ChatRequest.messages.
Only implements ChatBroker. Anthropic doesn't host first-party embeddings (they partner with Voyage AI); pair Anthropic with OpenAiBroker or GeminiBroker for the embed side of a RAG pipeline.
- Inheritance
-
- Object
- ChatBroker
- AnthropicBroker
Constructors
- AnthropicBroker({Client? client})
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 setteroverride - label → String
-
Human label for picker UIs.
'OpenAI','Anthropic (Claude)','Google (Gemini)','Google (Translate)'.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.
Same call as chatWithMeta, keeping only
AiCompletion.text.inherited -
chatWithMeta(
{required String apiKey, required String model, required ChatRequest request}) → Future< AiCompletion> -
Multi-turn, returning the final turn's reply with why the model
stopped and the token counts the provider reported. Every provider
call goes through here; chat, complete and completeWithMeta
are built on it.
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. Same call as
completeWithMeta, keeping only
AiCompletion.text.inherited -
completeWithMeta(
{required String apiKey, required String model, required String system, required String user, double temperature = 0.3, int maxTokens = 2048}) → Future< AiCompletion> -
Single-shot, returning the reply with why the model stopped and the
token counts the provider reported. Use it to tell a reply cut off at
maxTokens(AiFinishReason.maxTokens) from a complete one.inherited -
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).
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