Skip to main content

Crate kcode_gemini_api

Crate kcode_gemini_api 

Source
Expand description

Gemini inference with in-memory session usage accounting and spending limits.

Gemini intentionally supports Gemini 3.1 Flash-Lite, Gemini 3.1 Pro Preview, Nano Banana Pro, Pro multimodal inference, and Flash-Lite grounded search. Nothing is persisted by this crate.

Structs§

CostBreakdown
Locally calculated cost for one request or aggregate.
Gemini
Cloneable asynchronous Gemini client with shared in-memory session accounting.
GeneratedImage
A generated image returned by Nano Banana Pro.
GenerationOptions
Shared generation controls.
GroundedSearchRequest
Grounded Flash-Lite search request matching Kennedy fast search.
GroundedSearchResponse
Successful grounded-search output.
GroupedUsage
Usage totals grouped by one model or operation name.
InferenceRequest
One text-only inference request.
InferenceResponse
A successful text or image interaction.
LimitStatus
Current-session spend and configured limits for all three UTC periods.
MediaInput
One image, audio, or video input held in memory for an inference request.
ModalityTokens
One modality-specific token count.
Money
A non-negative USD amount represented exactly in billionths of one dollar.
MultimodalRequest
Image, audio, and/or video inference request for Gemini 3.1 Pro.
NanoBananaProRequest
Nano Banana Pro generation or editing request with fixed 2K output.
SpendingLimits
Optional spending limits for the current session’s UTC hour, day, and month.
StructuredOutput
A validated JSON Schema requesting JSON structured output.
TokenUsage
Token usage reported for one interaction.
UsageBreakdown
Complete current-session aggregate report for one selected window.
UsageRecord
One in-memory usage record. Prompts, media, responses, and credentials are not recorded.
UsageTotals
Aggregated request, token, and cost values.
WebSource
One public source returned by grounded search.

Enums§

AspectRatio
Native-image aspect ratio supported by Nano Banana Pro at 2K.
CompletionStatus
Final interaction state returned by Gemini.
CostAccuracy
Quality of a locally calculated cost.
Error
A local validation, accounting, transport, provider, or protocol failure.
LimitPeriod
UTC period used by one spending limit.
MediaKind
Inline media category accepted by Gemini 3.1 Pro.
Modality
Provider modality used for token accounting.
ServiceTier
Gemini inference service tier.
TextModel
Text inference models intentionally supported by this crate.
ThinkingLevel
Maximum model reasoning depth.
UsageWindow
Time selection for a current-session usage breakdown.

Constants§

GEMINI_31_FLASH_LITE
Stable Gemini 3.1 Flash-Lite model identifier.
GEMINI_31_PRO
Current Gemini 3.1 Pro preview model identifier.
NANO_BANANA_PRO
Stable Nano Banana Pro model identifier.

Type Aliases§

Result
The result type returned by this crate.