pub struct Credentials { /* private fields */ }
Expand description
Holds the API key and base URL for an OpenAI-compatible API.
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn new(api_key: impl Into<String>, base_url: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>, base_url: impl Into<String>) -> Self
Creates credentials with the given API key and base URL.
If the base URL is empty, it will use the default.
Sourcepub fn from_env() -> Credentials
pub fn from_env() -> Credentials
Fetches the credentials from the ENV variables OPENAI_KEY and OPENAI_BASE_URL.
§Panics
This function will panic if the key variable is missing from the env. If only the base URL variable is missing, it will use the default.
pub fn api_key(&self) -> &str
pub fn base_url(&self) -> &str
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
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 Credentials
impl Debug for Credentials
Source§impl PartialEq for Credentials
impl PartialEq for Credentials
impl Eq for Credentials
impl StructuralPartialEq for Credentials
Auto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnwindSafe for Credentials
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