pub struct OpenAIConfig {
pub api_key: SecretString,
pub model: String,
pub base_url: Option<Url>,
pub organization: Option<String>,
pub project: Option<String>,
pub http: HttpConfig,
pub embedding_model: Option<String>,
}Expand description
Configuration for the OpenAI provider.
Fields§
§api_key: SecretStringOpenAI API key
model: StringModel to use (e.g., “gpt-4”, “gpt-3.5-turbo”)
base_url: Option<Url>Base URL for the OpenAI API (defaults to https://api.openai.com/v1)
organization: Option<String>Organization ID (optional)
project: Option<String>Project ID (optional)
http: HttpConfigHTTP client configuration
embedding_model: Option<String>Embedding model to use (e.g., “text-embedding-ada-002”)
Implementations§
Source§impl OpenAIConfig
impl OpenAIConfig
Sourcepub fn new(api_key: impl Into<SecretString>, model: impl Into<String>) -> Self
pub fn new(api_key: impl Into<SecretString>, model: impl Into<String>) -> Self
Create a new OpenAI configuration with the given API key and model.
Sourcepub fn builder() -> OpenAIConfigBuilder
pub fn builder() -> OpenAIConfigBuilder
Create a configuration builder.
Sourcepub fn completions_url(&self) -> String
pub fn completions_url(&self) -> String
Get the completions endpoint URL.
Sourcepub fn embeddings_url(&self) -> String
pub fn embeddings_url(&self) -> String
Get the embeddings endpoint URL.
Sourcepub fn images_url(&self) -> String
pub fn images_url(&self) -> String
Get the images endpoint URL.
Sourcepub fn transcriptions_url(&self) -> String
pub fn transcriptions_url(&self) -> String
Get the audio transcriptions endpoint URL.
Sourcepub fn speech_url(&self) -> String
pub fn speech_url(&self) -> String
Get the audio speech endpoint URL.
Sourcepub fn from_env() -> Result<Self, ConfigError>
pub fn from_env() -> Result<Self, ConfigError>
Load configuration from environment variables.
Trait Implementations§
Source§impl Clone for OpenAIConfig
impl Clone for OpenAIConfig
Source§fn clone(&self) -> OpenAIConfig
fn clone(&self) -> OpenAIConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpenAIConfig
impl Debug for OpenAIConfig
Source§impl Default for OpenAIConfig
impl Default for OpenAIConfig
Source§impl<'de> Deserialize<'de> for OpenAIConfig
impl<'de> Deserialize<'de> for OpenAIConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl ProviderConfig for OpenAIConfig
impl ProviderConfig for OpenAIConfig
Auto Trait Implementations§
impl Freeze for OpenAIConfig
impl RefUnwindSafe for OpenAIConfig
impl Send for OpenAIConfig
impl Sync for OpenAIConfig
impl Unpin for OpenAIConfig
impl UnwindSafe for OpenAIConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more