A V language SDK for interacting with Google's Gemini AI API. This module provides a simple and efficient way to integrate Gemini's generative AI capabilities into your V applications.
- Support for multiple free Gemini models (1.5 Flash, 2.0 Flash, 2.5 Flash variants) - PRs welcome for paid models
- Simple prompt-based text generation
- Advanced request configuration with system instructions
- Comprehensive response handling
- Type-safe API with structured data models
- Built-in error handling
v install sdk_geminiimport sdk_gemini
import structs
// Initialize the SDK with your API key
mut sdk := sdk_gemini.GeminiSDK{
api_key: 'your-api-key-here'
}
// Send a simple prompt
response := sdk.send_prompt(
structs.Models.gemini_2_0_flash,
'Tell me about João Pessoa, Paraíba',
'You are a tour guide from Brazil, specifically from the Northeast region, João Pessoa and Paraíba state'
) or {
panic('Failed to get response: ${err}')
}
// Access the response
if response.candidates.len > 0 {
println(response.candidates[0].content.parts[0].text)
}The main SDK struct for interacting with the Gemini API.
pub struct GeminiSDK {
pub:
api_key string
}Sends a complete request to the Gemini API with full control over the request structure.
Parameters:
model: The Gemini model to use (see Models enum)req_payload: Complete request configuration
Returns: GeminiResponse or error
Simplified method for sending text prompts with optional system instructions.
Parameters:
model: The Gemini model to useprompt: The user prompt/questionsystem_instruction: Optional system instruction (can be empty string)
Returns: GeminiResponse or error
The SDK supports the following Gemini models:
gemini_1_5_flash_8b- Gemini 1.5 Flash 8Bgemini_1_5_flash- Gemini 1.5 Flashgemini_2_0_flash- Gemini 2.0 Flashgemini_2_0_flash_lite- Gemini 2.0 Flash Litegemini_2_0_flash_thinking_exp_01_21- Gemini 2.0 Flash Thinking (Experimental)gemini_2_5_flash- Gemini 2.5 Flash
MIT License
Contributions are welcome! Please feel free to submit issues and pull requests.