| Crates.io | aiassist |
| lib.rs | aiassist |
| version | 0.1.3 |
| created_at | 2024-12-31 16:47:31.603231+00 |
| updated_at | 2024-12-31 16:50:52.014046+00 |
| description | Rust library for interacting with Google's Gemini API |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1500178 |
| size | 51,530 |
A Rust library for interacting with multiple AI providers including Google's Gemini API, OpenAI's GPT, and Anthropic's Claude. This library provides a simple and unified way to integrate AI capabilities into your Rust applications.
Add this to your Cargo.toml:
[dependencies]
aiassist = "0.1.0"
First, you'll need to get API keys from the providers you want to use. Then you can use the library like this:
use aiassist::{GeminiClient, OpenAIClient, ClaudeClient, ClientConfig, AIClient};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Configure clients
let gemini_config = ClientConfig {
api_key: std::env::var("GEMINI_API_KEY")?,
timeout_secs: 30,
};
let openai_config = ClientConfig {
api_key: std::env::var("OPENAI_API_KEY")?,
timeout_secs: 30,
};
let claude_config = ClientConfig {
api_key: std::env::var("ANTHROPIC_API_KEY")?,
timeout_secs: 30,
};
// Initialize clients
let gemini = GeminiClient::new(gemini_config);
let openai = OpenAIClient::new(openai_config);
let claude = ClaudeClient::new(claude_config);
// Generate content using different providers
let prompt = "Tell me about Rust programming language";
let gemini_response = gemini.generate_content(prompt).await?;
println!("Gemini: {}", gemini_response);
let openai_response = openai.generate_content(prompt).await?;
println!("OpenAI: {}", openai_response);
let claude_response = claude.generate_content(prompt).await?;
println!("Claude: {}", claude_response);
Ok(())
}
GEMINI_API_KEY: Your Google Gemini API keyOPENAI_API_KEY: Your OpenAI API keyANTHROPIC_API_KEY: Your Anthropic API keyThe library uses anyhow for error handling. All errors are wrapped in anyhow::Result, making it easy to handle different types of errors that might occur during API calls.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.