pub struct OpenAiClient { /* private fields */ }Expand description
An OpenAI-compatible chat client over a configurable base URL.
Implementations§
Source§impl OpenAiClient
impl OpenAiClient
pub fn new(base_url: impl Into<String>, api_key: Option<String>) -> Self
Sourcepub async fn list_models(&self) -> Result<Vec<DiscoveredModel>>
pub async fn list_models(&self) -> Result<Vec<DiscoveredModel>>
Discover the models this endpoint+key can access via GET /models.
Sorted cheapest→most-expensive where pricing is reported (others last),
so the result doubles as a price-ordered tier ladder.
Sourcepub async fn chat_stream(
&self,
req: &ChatRequest,
events: &EventSink,
cancel: &CancellationToken,
) -> Result<ChatResponse>
pub async fn chat_stream( &self, req: &ChatRequest, events: &EventSink, cancel: &CancellationToken, ) -> Result<ChatResponse>
Stream a chat completion, emitting each content delta as a
WorkerEvent::Message and returning the accumulated response.
Trait Implementations§
Source§impl ChatBackend for OpenAiClient
impl ChatBackend for OpenAiClient
fn complete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
events: &'life2 EventSink,
cancel: &'life3 CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§impl Clone for OpenAiClient
impl Clone for OpenAiClient
Source§fn clone(&self) -> OpenAiClient
fn clone(&self) -> OpenAiClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for OpenAiClient
impl !UnwindSafe for OpenAiClient
impl Freeze for OpenAiClient
impl Send for OpenAiClient
impl Sync for OpenAiClient
impl Unpin for OpenAiClient
impl UnsafeUnpin for OpenAiClient
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