pub struct OpenAiCompatEnvironmentImpl { /* private fields */ }Expand description
Environment configuration trait and default implementation. Environment configuration trait and default implementation. Default OpenAI-compatible environment backed by in-memory values.
Construct with new(), then chain
builder methods to override defaults.
§Examples
use api_openai_compatible::OpenAiCompatEnvironmentImpl;
let env = OpenAiCompatEnvironmentImpl::new( "sk-..." ).unwrap();
// override base URL for a KIE.ai model slug:
let kie_env = env.with_base_url( "https://api.kie.ai/my-model/v1/" );Implementations§
Source§impl OpenAiCompatEnvironmentImpl
impl OpenAiCompatEnvironmentImpl
Sourcepub const DEFAULT_BASE_URL: &'static str = "https://api.openai.com/v1/"
pub const DEFAULT_BASE_URL: &'static str = "https://api.openai.com/v1/"
Default base URL for the OpenAI API.
Sourcepub const DEFAULT_TIMEOUT_SECS: u64 = 30
pub const DEFAULT_TIMEOUT_SECS: u64 = 30
Default request timeout in seconds.
Sourcepub fn new(api_key: impl Into<String>) -> Result<Self>
pub fn new(api_key: impl Into<String>) -> Result<Self>
Creates a new environment with default base URL and 30-second timeout.
§Arguments
api_key— API authentication key. May be anyInto<String>.
§Errors
Returns an error if api_key is empty or otherwise invalid.
§Examples
use api_openai_compatible::OpenAiCompatEnvironmentImpl;
let env = OpenAiCompatEnvironmentImpl::new( "sk-mykey" ).unwrap();Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Overrides the base URL, returning the modified environment.
Use this to target non-standard endpoints such as KIE.ai model-slug
URLs ("https://api.kie.ai/{slug}/v1/") or local development proxies.
§Examples
use api_openai_compatible::OpenAiCompatEnvironmentImpl;
let env = OpenAiCompatEnvironmentImpl::new( "sk-key" ).unwrap()
.with_base_url( "https://api.kie.ai/gpt-4o/v1/" );Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Overrides the request timeout, returning the modified environment.
§Examples
use api_openai_compatible::OpenAiCompatEnvironmentImpl;
use core::time::Duration;
let env = OpenAiCompatEnvironmentImpl::new( "sk-key" ).unwrap()
.with_timeout( Duration::from_secs( 60 ) );Trait Implementations§
Source§impl Clone for OpenAiCompatEnvironmentImpl
impl Clone for OpenAiCompatEnvironmentImpl
Source§fn clone(&self) -> OpenAiCompatEnvironmentImpl
fn clone(&self) -> OpenAiCompatEnvironmentImpl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenAiCompatEnvironmentImpl
impl Debug for OpenAiCompatEnvironmentImpl
Source§impl OpenAiCompatEnvironment for OpenAiCompatEnvironmentImpl
impl OpenAiCompatEnvironment for OpenAiCompatEnvironmentImpl
Auto Trait Implementations§
impl Freeze for OpenAiCompatEnvironmentImpl
impl RefUnwindSafe for OpenAiCompatEnvironmentImpl
impl Send for OpenAiCompatEnvironmentImpl
impl Sync for OpenAiCompatEnvironmentImpl
impl Unpin for OpenAiCompatEnvironmentImpl
impl UnsafeUnpin for OpenAiCompatEnvironmentImpl
impl UnwindSafe for OpenAiCompatEnvironmentImpl
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
Source§type Val = <C as Collection>::Val
type Val = <C as Collection>::Val
Entry in complex collections.
For example, in a HashMap, while Entry might be a ( key, value ) tuple, Val might only be the value part.Source§fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
Source§fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
Invokes the val_to_entry function of the CollectionValToEntry trait to convert the value to an entry.
Source§type Entry = <C as CollectionValToEntry<Val>>::Entry
type Entry = <C as CollectionValToEntry<Val>>::Entry
Entry is defined by the Collection trait.