pub struct ModelId(/* private fields */);Expand description
A Gemini model identifier, exactly as the API accepts it.
Either the resource form models/gemini-… or a bare gemini-… name; the
wire layer normalises whichever you give it. This is a string newtype
rather than an enum on purpose: the model catalog changes faster than any
release cycle, and an enum of “known” models guarantees that the named
variants are the stale ones while the real work goes through an escape
hatch. The known-good names live here as constants instead, so they are
discoverable without being the only thing that typechecks.
use gemini_genai_rs::prelude::ModelId;
let a: ModelId = "models/gemini-2.5-flash-native-audio-latest".into();
let b = ModelId::new(String::from("gemini-flash-latest"));
let c = ModelId::LIVE_2_5_FLASH_NATIVE_AUDIO;
assert_eq!(a.as_str(), "models/gemini-2.5-flash-native-audio-latest");
assert_ne!(b, c);Leave the model unset on SessionConfig
and connect resolves a platform-appropriate default via
ModelId::live_default; set it only when you need a specific model.
Implementations§
Source§impl ModelId
impl ModelId
Sourcepub const LIVE_2_5_FLASH_NATIVE_AUDIO: ModelId
pub const LIVE_2_5_FLASH_NATIVE_AUDIO: ModelId
Vertex AI’s GA Live model name (per Google Cloud docs).
Sourcepub const FLASH_2_5_NATIVE_AUDIO_LATEST: ModelId
pub const FLASH_2_5_NATIVE_AUDIO_LATEST: ModelId
Google AI’s rolling alias for the current native-audio Live model. Verified reachable on Google AI 2026-08; the dated names it aliases are retired without notice, which is why the alias is the default.
Sourcepub const FLASH_LATEST: ModelId
pub const FLASH_LATEST: ModelId
Google AI’s rolling alias for the current Flash text model
(generateContent). Dated gemini-2.5-flash names 404 there.
Sourcepub const fn from_static(id: &'static str) -> Self
pub const fn from_static(id: &'static str) -> Self
A model id from a 'static string, usable in const context.
Sourcepub fn qualified(id: impl Into<String>) -> Self
pub fn qualified(id: impl Into<String>) -> Self
A model id with the models/ resource prefix added when the name is
bare (contains no /). Qualified names — models/…, projects/… —
pass through untouched.
Sourcepub fn bare_name(&self) -> &str
pub fn bare_name(&self) -> &str
The identifier without a leading models/, which is the form Vertex
AI wants inside its publisher path.
Sourcepub fn live_default(vertex: bool) -> Self
pub fn live_default(vertex: bool) -> Self
The Live model to use when none was set: GEMINI_LIVE_MODEL if set,
else GEMINI_MODEL, else the platform’s current native-audio Flash
model.
GEMINI_LIVE_MODEL exists because GEMINI_MODEL is also the text
model override (GeminiLlm reads GEMINI_TEXT_MODEL, then
GEMINI_MODEL): a native-audio name in the shared variable would 404
every generateContent call. A bare name (no /) gets the models/
prefix the wire expects; a qualified one passes through untouched.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ModelId
impl<'de> Deserialize<'de> for ModelId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ModelId
impl StructuralPartialEq for ModelId
Auto Trait Implementations§
impl Freeze for ModelId
impl RefUnwindSafe for ModelId
impl Send for ModelId
impl Sync for ModelId
impl Unpin for ModelId
impl UnwindSafe for ModelId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].