GeminiClient class

Native Google Gemini API client with SSE streaming support.

Unlike OpenAI-compatible providers, the Gemini REST API uses a completely different authentication scheme (query-parameter API key instead of Bearer token), endpoint layout (/models/{model}:streamGenerateContent), and message format (contents / parts instead of messages).

This client translates the app's internal Message model into Gemini's request format and converts Gemini's SSE responses back into the unified StreamEvent types used throughout the codebase.

Inheritance

Constructors

GeminiClient(ApiConfig config)
Creates a client with the given Gemini config.

Properties

config ApiConfig
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createMessage({required List<Message> messages, required String systemPrompt, List<ToolDefinition> tools = const [], int? maxTokens}) Future<Message>
Send a non-streaming completion via the Gemini generateContent endpoint.
override
createMessageStream({required List<Message> messages, required String systemPrompt, List<ToolDefinition> tools = const [], int? maxTokens}) Stream<StreamEvent>
Stream a message completion via the Gemini streamGenerateContent endpoint.
override
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