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 OpenAI-compatible provider.

use derive_builder::Builder;

/// Settings for the OpenAI-compatible provider (delegates to OpenAI).
#[derive(Debug, Clone, Builder)]
#[builder(setter(into), default)]
pub struct OpenAICompatibleSettings {
    /// The name of the provider. Defaults to "OpenAICompatible".
    pub provider_name: String,

    /// The base URL for the OpenAI-compatible API.
    pub base_url: String,

    /// The API key for the OpenAI-compatible API.
    pub api_key: String,

    /// Custom API path override.
    pub path: Option<String>,
}

impl Default for OpenAICompatibleSettings {
    /// Returns the default settings for the OpenAI-compatible provider.
    fn default() -> Self {
        Self {
            provider_name: "OpenAICompatible".to_string(),
            base_url: "https://api.openai.com/v1".to_string(),
            api_key: std::env::var("OPENAI_API_KEY").unwrap_or_default(),
            path: None,
        }
    }
}

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