pub struct OpenAIClient { /* private fields */ }Implementations§
Source§impl OpenAIClient
impl OpenAIClient
Sourcepub fn new(base_url: impl Into<String>) -> Result<Self>
pub fn new(base_url: impl Into<String>) -> Result<Self>
Create a new client with the specified base URL
Sourcepub fn with_api_key(
base_url: impl Into<String>,
api_key: impl Into<String>,
) -> Result<Self>
pub fn with_api_key( base_url: impl Into<String>, api_key: impl Into<String>, ) -> Result<Self>
Create a new client with the specified base URL and API key
Sourcepub async fn list_models(&self) -> Result<ChatModelResponse>
pub async fn list_models(&self) -> Result<ChatModelResponse>
get all models
Sourcepub async fn chat_completion(
&self,
request: ChatCompletionRequest,
) -> Result<ChatCompletionResponse>
pub async fn chat_completion( &self, request: ChatCompletionRequest, ) -> Result<ChatCompletionResponse>
Send a chat completion request
Sourcepub async fn chat_completion_stream(
&self,
request: ChatCompletionRequest,
) -> Result<impl Stream<Item = Result<ChatCompletionChunk>>>
pub async fn chat_completion_stream( &self, request: ChatCompletionRequest, ) -> Result<impl Stream<Item = Result<ChatCompletionChunk>>>
Send a streaming chat completion request
Trait Implementations§
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 · 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 Freeze for OpenAIClient
impl !RefUnwindSafe for OpenAIClient
impl Send for OpenAIClient
impl Sync for OpenAIClient
impl Unpin for OpenAIClient
impl UnsafeUnpin for OpenAIClient
impl !UnwindSafe 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