Skip to main content

Crate ferrin_google

Crate ferrin_google 

Source
Expand description

Ferrin provider for Google Generative AI (Gemini API).

Implements the ferrin-spec traits for generateContent (non-streaming and streaming), embeddings, Gemini image generation, speech (TTS), transcription, Veo video generation, the Files API, batch generation and Live API sessions, plus factories for the Google provider-executed tools.

§Examples

use ferrin_google::GoogleSettings;
use ferrin_google::create_google;
use ferrin_spec::LanguageModel;
use ferrin_spec::language_model::CallOptions;
use ferrin_spec::language_model::PromptMessage;

let google = create_google(GoogleSettings::default())?;
let model = google.language_model("gemini-2.5-flash");
let result = model
    .do_generate(CallOptions::new(vec![PromptMessage::user_text("Hello")]))
    .await?;
println!("{:?}", result.content);

Capability matrix and provider options: docs/providers/google.md.

§Attribution

Portions of this crate are derived from the Vercel AI SDK (Apache-2.0, Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and modified. See the NOTICE file in the crate root.

Re-exports§

pub use crate::batch::GoogleBatch;
pub use crate::config::GoogleConfig;
pub use crate::config::SharedConfig;
pub use crate::embedding::GoogleEmbeddingModel;
pub use crate::files::GoogleFiles;
pub use crate::image::GoogleImageModel;
pub use crate::language_model::GoogleLanguageModel;
pub use crate::realtime::GoogleRealtimeFactory;
pub use crate::realtime::GoogleRealtimeModel;
pub use crate::speech::GoogleSpeechModel;
pub use crate::speech_translation::GoogleSpeechTranslationModel;
pub use crate::speech_translation::GoogleSpeechTranslationOptions;
pub use crate::tools::GoogleTools;
pub use crate::transcription::GoogleTranscriptionModel;
pub use crate::video::GoogleVideoModel;

Modules§

api_types
Wire types of the generateContent responses (requests are built as JSON objects in crate::request).
batch
Batch generation (batchGenerateContent): inline or file-based input, status, results, cancel and list.
capabilities
Model capabilities inferred from the model id.
config
Shared configuration of every Google model and service.
convert_prompt
Conversion of the specification prompt to systemInstruction and contents.
embedding
Gemini embedding model (embedContent / batchEmbedContents).
error
Google error response schema.
files
Files API: resumable upload with processing poll, metadata and delete.
image
Gemini image generation (generateContent with the IMAGE modality).
json_accumulator
Incremental reconstruction of function call arguments streamed as partialArgs (JSON path plus scalar value) into JSON text deltas.
json_schema
Conversion of JSON Schema (draft 7) to the OpenAPI 3.0 schema subset accepted by the Gemini API (responseSchema, function parameters).
language_model
Gemini language model (generateContent / streamGenerateContent).
options
Provider options read from provider_options["google"] (and the configured provider name when it differs).
output
Mapping of generateContent responses to specification content, usage, finish reasons and provider metadata.
prepare_tools
Conversion of tool definitions and tool choice to tools and toolConfig.
realtime
Live API realtime model: ephemeral auth tokens, session setup and the mapping between Live API messages and the specification events.
request
Request body construction (generateContent).
speech
Gemini text-to-speech model (generateContent with AUDIO modality).
speech_translation
Google Live speech translation adapted from Vercel AI SDK (Apache-2.0, Copyright 2023 Vercel, Inc.); see the root NOTICE.
stream
Streaming state machine for streamGenerateContent?alt=sse.
tools
Factories for Google provider-executed tools.
transcription
Gemini transcription over Interactions and feature-gated Live streaming.
video
Veo video generation (predictLongRunning operations).

Structs§

GoogleInteractionOptions
Headers and cancellation for an existing Interactions resource.
GoogleInteractionsLanguageModel
A language model backed by Google’s Interactions API.
GoogleProvider
The Google provider: a factory for the models and services.
GoogleSettings
Settings of create_google.

Constants§

VERSION
Crate version.

Functions§

create_google
Creates a Google Generative AI provider.