GeminiProvider class

Streams generateContent responses from Google's Gemini API.

Gemini's wire format genuinely differs from OpenAI-compatible APIs (see OpenRouterProvider): the API key is a query parameter rather than an Authorization header, roles are user/model rather than user/assistant, and system instructions are a separate top-level field rather than a message with role system.

Inheritance

Constructors

GeminiProvider({required String apiKey, required String model, Client? httpClient, Uri? endpoint, List<Map<String, Object?>>? functionDeclarations, Map<String, Object?>? extraParams})
Creates a Gemini provider.

Properties

apiKey String
Your Gemini API key.
final
extraParams Map<String, Object?>?
Extra body fields merged in, e.g. {'generationConfig': {...}}.
final
functionDeclarations List<Map<String, Object?>>?
Raw Gemini-shaped function-declaration schemas, passed through as tools: [{functionDeclarations: ...}]. null omits the field.
final
hashCode int
The hash code for this object.
no setterinherited
model String
Model id, e.g. gemini-1.5-pro or gemini-2.0-flash.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asResponder({List<ChatMessage> history()?}) AgentResponder
Adapts this provider to AgentResponder, for ChatController's managed send().
inherited
dispose() → void
Releases resources held by this provider.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendMessage(ChatController controller, String text, {List<Attachment>? attachments}) Future<void>
Drives controller's manual streaming API directly, so tool calls surface as ToolCalls instead of being dropped.
inherited
streamEvents(List<ChatMessage> conversation) Stream<ProviderEvent>
Streams structured events for conversation's next assistant turn.
override
toString() String
A string representation of this object.
inherited

Operators

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