pub struct GeminiClient { /* private fields */ }Expand description
HTTP client for interacting with Google’s Gemini Embeddings API.
This client provides methods to generate text embeddings using Google’s gemini-embedding-001 model. Embeddings are vector representations of text that can be used for semantic search, clustering, and similarity comparisons.
§Security
The API key is securely transmitted via the x-goog-api-key HTTP header,
not in the URL, to prevent accidental exposure in logs and proxies.
§Examples
use ceres_client::GeminiClient;
let client = GeminiClient::new("your-api-key")?;
let embedding = client.get_embeddings("Hello, world!").await?;
println!("Embedding dimension: {}", embedding.len()); // 768Implementations§
Source§impl GeminiClient
impl GeminiClient
Sourcepub fn new(api_key: &str) -> Result<Self, AppError>
pub fn new(api_key: &str) -> Result<Self, AppError>
Creates a new Gemini client with the specified API key.
Sourcepub async fn get_embeddings(&self, text: &str) -> Result<Vec<f32>, AppError>
pub async fn get_embeddings(&self, text: &str) -> Result<Vec<f32>, AppError>
Generates text embeddings using Google’s gemini-embedding-001 model.
This method converts input text into a 768-dimensional vector representation that captures semantic meaning.
§Arguments
text- The input text to generate embeddings for
§Returns
A vector of 768 floating-point values representing the text embedding.
§Errors
Returns AppError::ClientError if the HTTP request fails.
Returns AppError::Generic if the API returns an error.
Trait Implementations§
Source§impl Clone for GeminiClient
impl Clone for GeminiClient
Source§fn clone(&self) -> GeminiClient
fn clone(&self) -> GeminiClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more