pub struct Gemini { /* private fields */ }Expand description
Calls the Gemini Developer API.
The key is held here and never journaled — transport metadata in exactly the sense a peer credential is, and the same rule applies: a secret in a hash-chained record cannot be redacted afterwards, only discovered.
Implementations§
Source§impl Gemini
impl Gemini
pub const DEFAULT_TIMEOUT: Duration
Sourcepub const DEFAULT_BASE: &'static str = "https://generativelanguage.googleapis.com"
pub const DEFAULT_BASE: &'static str = "https://generativelanguage.googleapis.com"
The default endpoint.
Sourcepub const VERSION: &'static str = "v1beta"
pub const VERSION: &'static str = "v1beta"
The API version this driver speaks.
Pinned rather than tracking the newest, for the reason every version here is pinned: a provider that changes its response shape under a running plane changes what replay reads back.
Sourcepub fn from_env() -> Result<Self, ModelError>
pub fn from_env() -> Result<Self, ModelError>
Take the key from GEMINI_API_KEY, falling back to GOOGLE_API_KEY.
Both are read because both are in wide use and a deployment that exported the other one would otherwise get an authentication failure naming neither.
§Errors
If neither variable is set, or the HTTP client cannot be built.
Sourcepub fn base(self, base: impl Into<String>) -> Self
pub fn base(self, base: impl Into<String>) -> Self
Point at another endpoint — a regional host, or a test double.
Sourcepub const fn timeout(self, timeout: Duration) -> Self
pub const fn timeout(self, timeout: Duration) -> Self
Bound connection, generation, and response streaming as one operation.
Sourcepub fn structured_via(self, mode: SchemaMode) -> Self
pub fn structured_via(self, mode: SchemaMode) -> Self
How to obtain a schema-conforming answer from every model.
Sourcepub fn structured_via_for(
self,
model: impl Into<String>,
mode: SchemaMode,
) -> Self
pub fn structured_via_for( self, model: impl Into<String>, mode: SchemaMode, ) -> Self
How to obtain a schema-conforming answer from one model.
Sourcepub fn safety(self, safety: SafetySettings) -> Self
pub fn safety(self, safety: SafetySettings) -> Self
Apply the deployment’s own safety thresholds to every call.
See SafetySettings for the posture. In short: this crate ships no
classifier, Google’s is configured here, and what the runtime owns is
that the choice is effect identity and that an intervention is a
metered refusal rather than an answer.
Sourcepub fn egress(self, egress: Egress) -> Self
pub fn egress(self, egress: Egress) -> Self
Restrict where this driver may connect.
Deny-by-default once set — see Egress.
Sourcepub const fn buffered(self) -> Self
pub const fn buffered(self) -> Self
Ask for the whole response at once instead of streaming it.
Streaming is the default for the reason it is elsewhere in this crate:
Gemini reports usageMetadata in the stream, so a severed connection can
say what it burned rather than being billed as zero and retried for free.
Trait Implementations§
Source§impl ModelProvider for Gemini
impl ModelProvider for Gemini
Auto Trait Implementations§
impl !RefUnwindSafe for Gemini
impl !UnwindSafe for Gemini
impl Freeze for Gemini
impl Send for Gemini
impl Sync for Gemini
impl Unpin for Gemini
impl UnsafeUnpin for Gemini
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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