| Crates.io | nutrition-ai |
| lib.rs | nutrition-ai |
| version | 0.1.1 |
| created_at | 2025-07-16 07:11:25.112062+00 |
| updated_at | 2025-07-18 11:33:13.166908+00 |
| description | Rust wrapper to analyze food nutrition using Google Gemini |
| homepage | |
| repository | https://github.com/virugamacoder/nutrition-ai-crates |
| max_upload_size | |
| id | 1755098 |
| size | 74,883 |
Analyze food images using Google Gemini AI with full nutritional breakdown โ written in pure Rust.
๐ Node.js developer? Use the official nutrition-ai npm package.
This crate replicates the functionality of nutrition-ai in Rust.
image/png or image/jpeg)use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use nutrition_ai::{GeminiRequest, MimeType, generate_answer};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let image_bytes = std::fs::read("img.png")?;
let file_base64 = STANDARD.encode(&image_bytes);
let req = GeminiRequest {
file_base64,
file_mime_type: MimeType::ImagePng,
google_key: "<YOUR_GOOGLE_KEY>".to_string(),
model: Some("Gemini2_0Flash".to_string()),
};
let result = generate_answer(req).await?;
println!("{}", result);
Ok(())
}
| Field | Type | Description |
|---|---|---|
file_base64 |
String |
Base64-encoded food image |
file_mime_type |
MimeType enum |
MimeType::ImagePng or MimeType::ImageJpeg |
google_key |
String |
Your Google Gemini API key (get it from makersuite) |
model |
Option<String> |
Optional Gemini model (e.g. "Gemini2_0Flash") |
Gemini1_0ProGemini1_5ProGemini1_5Flash (default)Gemini1_5Flash8BGemini2_0FlashDefault fallback model if none is provided: Gemini1_5Flash
MIT ยฉ 2025