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::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::tools::GoogleTools;pub use crate::transcription::GoogleTranscriptionModel;pub use crate::video::GoogleVideoModel;
Modules§
- api_
types - Wire types of the
generateContentresponses (requests are built as JSON objects incrate::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
systemInstructionandcontents. - 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 (
generateContentwith theIMAGEmodality). - 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, functionparameters). - 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
generateContentresponses to specification content, usage, finish reasons and provider metadata. - prepare_
tools - Conversion of tool definitions and tool choice to
toolsandtoolConfig. - 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 (
generateContentwithAUDIOmodality). - stream
- Streaming state machine for
streamGenerateContent?alt=sse. - tools
- Factories for Google provider-executed tools.
- transcription
- Gemini transcription model (unary, Interactions API
POST /interactions). - video
- Veo video generation (
predictLongRunningoperations).
Structs§
- Google
Provider - The Google provider: a factory for the models and services.
- Google
Settings - Settings of
create_google.
Constants§
- VERSION
- Crate version.
Functions§
- create_
google - Creates a Google Generative AI provider.