ragzilla-embedding

Crates.ioragzilla-embedding
lib.rsragzilla-embedding
version0.2.0
created_at2025-03-21 20:39:23.003741+00
updated_at2025-03-22 15:59:20.275585+00
descriptionA Rust library for creating text embeddings using the Gemini API
homepage
repositoryhttps://github.com/excoffierleonard/ragzilla
max_upload_size
id1601137
size43,485
Leonard Excoffier (excoffierleonard)

documentation

https://docs.rs/ragzilla-embedding

README

ragzilla-embedding

A Rust library for creating text embeddings using the Gemini API.

Features

  • Generate text embeddings using Google's Gemini API
  • Simple async API that returns embedding vectors

Installation

Add the following to your Cargo.toml file:

[dependencies]
ragzilla-embedding = "0.1.0"

Usage

use ragzilla_embedding::create_embedding;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let api_key = std::env::var("GEMINI_API_KEY").expect("GEMINI_API_KEY must be set");
    let text = "What is the meaning of life?";

    let embedding = create_embedding(text, &api_key).await?;
    println!("Generated embedding with {} dimensions", embedding.len());

    Ok(())
}

API Reference

create_embedding

pub async fn create_embedding(text: &str, api_key: &str) -> Result<Vec<f32>, reqwest::Error>

Generates an embedding vector for the provided text using the Gemini API.

  • text: The text to create an embedding for
  • api_key: Your Gemini API key

Returns a Result containing a vector of floating-point values representing the embedding.

License

MIT License

Commit count: 0

cargo fmt