GeminiProvider

class GeminiProvider(apiKey: String, engine: HttpClientEngine = httpClientEngine()) : AiProvider(source)

Constructors

Link copied to clipboard
constructor(apiKey: String, engine: HttpClientEngine = httpClientEngine())

Properties

Link copied to clipboard
open override val displayName: String
Link copied to clipboard
open override val id: String

Functions

Link copied to clipboard
open suspend override fun capabilities(): AiCapabilities

Honest self-report for a capability-aware caller: whether this backend genuinely streams tokens and accepts images, which AiConfig fields it actually reads, and — when it can't run — the real AiFailure reason instead of a bare false. Default answer is conservative (no streaming, no honored config) and blames a missing key, matching every real provider's own isAvailable gate; a provider whose unavailability means something else overrides this.

Link copied to clipboard
open suspend override fun complete(messages: List<AiMessage>, config: AiConfig = AiConfig()): AiResult<String>

Runs one turn. Success carries the model's text; failure names why via AiFailure — a wrong/missing key, a rate limit, a timeout, any other transport problem, or a reply that came back empty. Never throws for an ordinary provider-side failure.

Link copied to clipboard
suspend fun AiProvider.completeOrBlank(messages: List<AiMessage>, config: AiConfig = AiConfig()): String

Bridge for callers not yet migrated off the pre-AiResult complete(): collapses every AiFailure back to "", matching the old runCatching { }.getOrElse { "" } behavior.

Link copied to clipboard
open override fun completeStream(messages: List<AiMessage>, config: AiConfig = AiConfig()): Flow<AiChunk>

Token-by-token variant of complete — so a UI can render the reply as it arrives and a Stop action actually cancels the in-flight request (cancelling the collecting coroutine tears down the underlying HTTP call) instead of leaving it running to completion in the background.

Link copied to clipboard
open suspend override fun isAvailable(): Boolean