aisdk 0.5.2

An open-source Rust library for building AI-powered applications, inspired by the Vercel AI SDK. It provides a robust, type-safe, and easy-to-use interface for interacting with various Large Language Models (LLMs).
Documentation
//! Defines the settings for the Google provider.

use derive_builder::Builder;
use serde::{Deserialize, Serialize};

/// Settings for the Google provider.
#[derive(Debug, Clone, Serialize, Deserialize, Builder)]
#[builder(setter(into), default)]
pub struct GoogleProviderSettings {
    /// The name of the provider.
    pub provider_name: String,

    /// The API base URL for the Google API.
    pub base_url: String,

    /// The API key for the Google API.
    pub api_key: String,

    /// Custom API path override. When set, this path is used instead of the
    /// default dynamic path (e.g., "/v1beta/models/{model}:generateContent").
    pub path: Option<String>,
}

impl Default for GoogleProviderSettings {
    /// Returns the default settings for the Google provider.
    fn default() -> Self {
        Self {
            provider_name: "google".to_string(),
            base_url: "https://generativelanguage.googleapis.com".to_string(),
            api_key: std::env::var("GOOGLE_API_KEY").unwrap_or_default(),
            path: None,
        }
    }
}

impl GoogleProviderSettings {
    /// Creates a new builder for `GoogleProviderSettings`.
    pub fn builder() -> GoogleProviderSettingsBuilder {
        GoogleProviderSettingsBuilder::default()
    }
}