GeminiClient class

A client for communicating with Google's Gemini API via REST.

Implements LlmClient to integrate seamlessly with the Vantura framework. Supports both standard generation and Server-Sent Events (SSE) streaming.

Implemented types

Constructors

GeminiClient({required String apiKey, String model = 'gemini-1.5-flash-latest', String? baseUrl, int maxTokens = 8192, double? temperature, void onRetry(int attempt, Duration nextDelay, dynamic error)?, Client? httpClient})
Creates a GeminiClient.

Properties

apiKey String
API key for authentication.
final
baseUrl String
Base URL for Gemini API.
final
hashCode int
The hash code for this object.
no setterinherited
maxTokens int
Default maximum tokens to sample.
final
model String
Default model to use for requests (e.g., gemini-1.5-flash-latest).
final
onRetry → void Function(int attempt, Duration nextDelay, dynamic error)?
Callback emitted when a request is about to be retried.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
temperature double?
Default temperature for responses.
final

Methods

close() → void
Closes the client and cleans up any resources.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendChatRequest(List<Map<String, dynamic>> messages, List<Map<String, dynamic>>? tools, {double? temperature, int? maxCompletionTokens, double? topP, bool? stream, String? reasoningEffort, dynamic stop, CancellationToken? cancellationToken}) Future<Map<String, dynamic>>
Sends a single, complete chat request to the LLM.
override
sendStreamingChatRequest(List<Map<String, dynamic>> messages, List<Map<String, dynamic>>? tools, {double? temperature, int? maxCompletionTokens, double? topP, String? reasoningEffort, dynamic stop, CancellationToken? cancellationToken}) Stream<Map<String, dynamic>>
Sends a streaming chat request to the LLM, yielding chunks as they arrive.
override
toString() String
A string representation of this object.
inherited

Operators

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