#artificial-intelligence #vector #rag #gemini #embedding #api-bindings

yanked ragzilla-embedding

A Rust library for creating text embeddings using the Gemini API

Uses new Rust 2024

0.2.0 Mar 22, 2025
0.1.0 Mar 21, 2025

#27 in #rag

Download history 182/week @ 2025-03-17 48/week @ 2025-03-24 3/week @ 2025-03-31

233 downloads per month

MIT license

12KB
59 lines

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

Dependencies

~4–17MB
~229K SLoC