Skip to content

GeminiClient

Category: LLM Providers

Source: gemini_client.dart

Streaming client for the Gemini Developer API (v1beta).

Talks to generativelanguage.googleapis.com via SSE streams. Unlike the other built-in LLM clients this also doubles as the data-parser that [GeminiProvider] delegates to — parseStreamEvents is exposed as a static for testability.

Classes

GeminiClient

Constructor

dart
GeminiClient({
    required this.apiKey,
    required this.model,
    required this.systemPrompt,
    String baseUrl = _defaultBaseUrl,
    http.Client Function()? requestClientFactory,
  })

Properties

PropertyTypeDescription
apiKeyString
modelString
systemPromptString

Methods

Stream<LlmChunk> stream(List<Message> messages, {List<Tool>? tools})
`static Stream<LlmChunk> parseStreamEvents(
Stream&lt;Map&lt;String, dynamic&gt;&gt; events,

)`

Parse Gemini SSE event payloads into [LlmChunk]s.

Exposed as static for testability — callers feed already-decoded JSON objects (one per SSE data: event).

Released under the MIT License.