Google Gemini API for Rust: ask_gemini
The ask_gemini crate is a powerful and easy-to-use Rust crate designed for making asynchronous API calls to the Google Gemini API. This library simplifies the process of sending prompts and fetching responses, handling all network and serialization tasks internally. It is ideal for developers looking to integrate Google Gemini API capabilities into their Rust applications efficiently.
Donate
Please consider supporting this project by donating:
- USDT / ETH / ... : 0xE4C3595D8a1F73F3b3EC0e7c75065C33B6C81f6D
- DASH: Xu6NwsnSyybjQ52vZKaU8txNurzc6FudFz
- Bitcoin (TRX): TE6Y5CNyLDCeZjChTf7wFAuRfFznPdREoR
- Bitcoin (BTC): 1PH8EnCMxWNwvFKsk8PxSx66f8CF9kiyw1
Features
- Asynchronous API Calls: Built on top of
tokioandreqwest,ask_geminioffers non-blocking API calls to Gemini. - Error Handling: Comprehensive error handling that provides clear error messages related to network issues or data serialization.
- Customizable: Supports custom API keys and model specifications, with defaults provided for immediate setup and use.
- Secure: Implements best practices for safe API requests and ensures data integrity.
Installation
Add ask_gemini to your Cargo.toml:
[]
= "0.1.0"
Or using cargo:
Usage
Below is a simple example on how to use ask_gemini to send a prompt to the Gemini API and receive a response:
use Gemini;
async
Configuration
- API Key: Ensure you have a valid API key from the Gemini API. This can be specified when creating an instance of
Geminior set as an environment variableGEMINI_API_KEY. - Model: Optionally specify the model when creating an instance of
Gemini. The default model is used if none is specified.
Contributions
Contributions are welcome! Please feel free to submit pull requests or create issues for bugs, questions, or new features.