pub struct GeminiClient { /* private fields */ }Expand description
Gemini API client.
Implementations§
Source§impl GeminiClient
impl GeminiClient
pub fn new(config: ProviderConfig) -> Self
Sourcepub fn from_api_key(
api_key: impl Into<String>,
model: impl Into<String>,
) -> Self
pub fn from_api_key( api_key: impl Into<String>, model: impl Into<String>, ) -> Self
Quick constructor for Google AI Studio (API key auth).
Sourcepub async fn call<T: JsonSchema + DeserializeOwned>(
&self,
messages: &[Message],
tools: &[ToolDef],
) -> Result<SgrResponse<T>, SgrError>
pub async fn call<T: JsonSchema + DeserializeOwned>( &self, messages: &[Message], tools: &[ToolDef], ) -> Result<SgrResponse<T>, SgrError>
SGR call: structured output (typed response) + function calling (tools).
Returns SgrResponse<T> where:
output: parsed structured response (if model returned text)tool_calls: function calls (if model used tools)
The model may return either or both.
Sourcepub async fn structured<T: JsonSchema + DeserializeOwned>(
&self,
messages: &[Message],
) -> Result<T, SgrError>
pub async fn structured<T: JsonSchema + DeserializeOwned>( &self, messages: &[Message], ) -> Result<T, SgrError>
SGR call with structured output only (no tools).
Shorthand for call::<T>(messages, &[]).
Sourcepub async fn flexible<T: JsonSchema + DeserializeOwned>(
&self,
messages: &[Message],
) -> Result<SgrResponse<T>, SgrError>
pub async fn flexible<T: JsonSchema + DeserializeOwned>( &self, messages: &[Message], ) -> Result<SgrResponse<T>, SgrError>
Flexible call: no structured output API, parse JSON from raw text.
For use with text-only proxies (CLI proxy, Codex proxy) where the model can’t enforce JSON schema. Uses AnyOf cascade + coercion.
Auto-injects JSON Schema into the system prompt so the model knows the expected format (like BAML does).
Trait Implementations§
Source§impl LlmClient for GeminiClient
impl LlmClient for GeminiClient
Source§fn structured_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
schema: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<(Option<Value>, Vec<ToolCall>, String), SgrError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn structured_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
schema: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<(Option<Value>, Vec<ToolCall>, String), SgrError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Structured call: send messages with schema injected into system prompt.
Returns (parsed_output, native_tool_calls, raw_text).
Source§fn tools_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolCall>, SgrError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn tools_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolCall>, SgrError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Native function calling: send messages + tool defs, get tool calls.
Auto Trait Implementations§
impl Freeze for GeminiClient
impl !RefUnwindSafe for GeminiClient
impl Send for GeminiClient
impl Sync for GeminiClient
impl Unpin for GeminiClient
impl UnsafeUnpin for GeminiClient
impl !UnwindSafe for GeminiClient
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
Mutably borrows from an owned value. Read more