pub struct OpenAiConfig { /* private fields */ }Expand description
OpenAI credentials and endpoint configuration.
let config = providers_kit::config::OpenAiConfig::new(
providers_kit::config::ApiKey::new("sk-test")?,
);
let _ = config;
Implementations§
Source§impl OpenAiConfig
impl OpenAiConfig
Sourcepub fn new(api_key: ApiKey) -> Self
pub fn new(api_key: ApiKey) -> Self
Creates a configuration for the public OpenAI endpoint.
This only constructs configuration; provider operations perform network I/O.
§Examples
use providers_kit::config::{ApiKey, OpenAiConfig};
let config = OpenAiConfig::new(ApiKey::new("example-key")?);
let _owned_configuration = config;
Sourcepub fn with_base_url(self, base_url: Url) -> Self
pub fn with_base_url(self, base_url: Url) -> Self
Replaces the API base URL.
This only constructs configuration; provider operations perform network I/O.
§Examples
use providers_kit::config::{ApiKey, OpenAiConfig};
let config = OpenAiConfig::new(ApiKey::new("example-key")?);
let config = config.with_base_url("https://example.com/api".parse().unwrap());
let _owned_configuration = config;
Sourcepub fn with_organization(
self,
organization: impl Into<String>,
) -> Result<Self, KitError>
pub fn with_organization( self, organization: impl Into<String>, ) -> Result<Self, KitError>
Sets the optional organization header.
§Errors
Returns a configuration error for an empty or padded value, or one that cannot be represented as an HTTP header value.
§Examples
use providers_kit::config::{ApiKey, OpenAiConfig};
let config = OpenAiConfig::new(ApiKey::new("example-key")?);
assert!(config.clone().with_organization(" padded ").is_err());
let _config = config.with_organization("team-1")?;
Sourcepub fn with_project(self, project: impl Into<String>) -> Result<Self, KitError>
pub fn with_project(self, project: impl Into<String>) -> Result<Self, KitError>
Sets the optional project header.
§Errors
Returns a configuration error for an empty or padded value, or one that cannot be represented as an HTTP header value.
§Examples
use providers_kit::config::{ApiKey, OpenAiConfig};
let config = OpenAiConfig::new(ApiKey::new("example-key")?);
assert!(config.clone().with_project(" padded ").is_err());
let _config = config.with_project("team-1")?;
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OpenAiConfig
impl RefUnwindSafe for OpenAiConfig
impl Send for OpenAiConfig
impl Sync for OpenAiConfig
impl Unpin for OpenAiConfig
impl UnsafeUnpin 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