dependabot[bot] 71e2440e0b Bump rustls-webpki from 0.103.8 to 0.103.10
Bumps [rustls-webpki](https://github.com/rustls/webpki) from 0.103.8 to 0.103.10.
- [Release notes](https://github.com/rustls/webpki/releases)
- [Commits](https://github.com/rustls/webpki/compare/v/0.103.8...v/0.103.10)

---
updated-dependencies:
- dependency-name: rustls-webpki
  dependency-version: 0.103.10
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-21 09:37:08 +00:00
2026-01-30 19:01:00 +00:00
2026-01-29 20:14:49 +00:00
2026-01-30 18:59:27 +00:00

google-genai

A Rust client library for the Google Generative AI API.

Building

To build the library, run the following command:

cargo build --release

Running Examples

The project includes several examples in the examples directory. To run an example, you'll first need to set up your environment with your Gemini API key.

  1. Create a .env file in the root of the project:

    GEMINI_API_KEY=your_api_key_here
    
  2. Run an example using cargo run:

    cargo run --example generate-content
    

Usage

To use this library in your own Rust application, add it as a dependency in your Cargo.toml file:

[dependencies]
google-genai = "0.1.0" # Or the latest version

Here is a basic example of how to use the GeminiClient to generate content:

use std::env;
use google_genai::prelude::{Content, GeminiClient, GenerateContentRequest, Role};

async fn run() -> Result<(), Box<dyn std::error::Error>> {
    // Get the API key from the environment.
    let api_key = env::var("GEMINI_API_KEY")?;

    // Create a new GeminiClient.
    let gemini_client = GeminiClient::new(api_key);

    // Build a prompt with a single user message.
    let prompt = vec![
        Content::builder()
            .role(Role::User)
            .add_text_part("What is the airspeed of an unladen swallow?")
            .build(),
    ];

    // Create the content generation request.
    let request = GenerateContentRequest::builder().contents(prompt).build();

    // Call the API to generate content.
    let response = gemini_client
        .generate_content(&request, "gemini-3-pro-preview")
        .await?;

    // Print the response.
    println!("Response: {:?}", response.candidates[0].get_text().unwrap());
    
    Ok(())
}
Description
No description provided
Readme 268 KiB
Languages
Rust 100%