pub struct DefaultClient { /* private fields */ }Expand description
Default client implementation backed by reqwest.
The provider is resolved at construction time from model_hint (or
defaults to OpenAI). However, individual requests can override the
provider when their model string contains a prefix that clearly
identifies a different provider (e.g. "anthropic/claude-3" will
route to Anthropic even if the client was built without a hint).
When the model prefix does not match any known provider, the construction-time provider is used as the fallback.
The provider is stored behind an Arc so it can be shared cheaply into
async closures and streaming tasks that must be 'static.
Implementations§
Source§impl DefaultClient
impl DefaultClient
Sourcepub fn new(config: ClientConfig, model_hint: Option<&str>) -> Result<Self>
pub fn new(config: ClientConfig, model_hint: Option<&str>) -> Result<Self>
Build a client.
model_hint guides provider auto-detection when no explicit
base_url override is present in the config. For example, passing
Some("groq/llama3-70b") selects the Groq provider. Pass None to
default to OpenAI.
§Errors
Returns a wrapped reqwest::Error if the underlying HTTP client
cannot be constructed. Header names and values are pre-validated by
ClientConfigBuilder::header, so they are inserted directly here.
Trait Implementations§
Source§impl BatchClient for DefaultClient
Available on crate features native-http or wasm-http only.
impl BatchClient for DefaultClient
native-http or wasm-http only.Source§fn create_batch(
&self,
req: CreateBatchRequest,
) -> BoxFuture<'_, Result<BatchObject>>
fn create_batch( &self, req: CreateBatchRequest, ) -> BoxFuture<'_, Result<BatchObject>>
Source§fn retrieve_batch(&self, batch_id: &str) -> BoxFuture<'_, Result<BatchObject>>
fn retrieve_batch(&self, batch_id: &str) -> BoxFuture<'_, Result<BatchObject>>
Source§fn list_batches(
&self,
query: Option<BatchListQuery>,
) -> BoxFuture<'_, Result<BatchListResponse>>
fn list_batches( &self, query: Option<BatchListQuery>, ) -> BoxFuture<'_, Result<BatchListResponse>>
Source§fn cancel_batch(&self, batch_id: &str) -> BoxFuture<'_, Result<BatchObject>>
fn cancel_batch(&self, batch_id: &str) -> BoxFuture<'_, Result<BatchObject>>
Source§impl Clone for DefaultClient
impl Clone for DefaultClient
Source§fn clone(&self) -> DefaultClient
fn clone(&self) -> DefaultClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl FileClient for DefaultClient
Available on crate features native-http or wasm-http only.
impl FileClient for DefaultClient
native-http or wasm-http only.Source§fn create_file(
&self,
req: CreateFileRequest,
) -> BoxFuture<'_, Result<FileObject>>
fn create_file( &self, req: CreateFileRequest, ) -> BoxFuture<'_, Result<FileObject>>
Source§fn retrieve_file(&self, file_id: &str) -> BoxFuture<'_, Result<FileObject>>
fn retrieve_file(&self, file_id: &str) -> BoxFuture<'_, Result<FileObject>>
Source§fn delete_file(&self, file_id: &str) -> BoxFuture<'_, Result<DeleteResponse>>
fn delete_file(&self, file_id: &str) -> BoxFuture<'_, Result<DeleteResponse>>
Source§fn list_files(
&self,
query: Option<FileListQuery>,
) -> BoxFuture<'_, Result<FileListResponse>>
fn list_files( &self, query: Option<FileListQuery>, ) -> BoxFuture<'_, Result<FileListResponse>>
Source§impl LlmClient for DefaultClient
Available on crate features native-http or wasm-http only.
impl LlmClient for DefaultClient
native-http or wasm-http only.Source§fn chat(
&self,
req: ChatCompletionRequest,
) -> BoxFuture<'_, Result<ChatCompletionResponse>>
fn chat( &self, req: ChatCompletionRequest, ) -> BoxFuture<'_, Result<ChatCompletionResponse>>
Source§fn chat_stream(
&self,
req: ChatCompletionRequest,
) -> BoxFuture<'_, Result<BoxStream<'static, Result<ChatCompletionChunk>>>>
fn chat_stream( &self, req: ChatCompletionRequest, ) -> BoxFuture<'_, Result<BoxStream<'static, Result<ChatCompletionChunk>>>>
Source§fn embed(
&self,
req: EmbeddingRequest,
) -> BoxFuture<'_, Result<EmbeddingResponse>>
fn embed( &self, req: EmbeddingRequest, ) -> BoxFuture<'_, Result<EmbeddingResponse>>
Source§fn list_models(&self) -> BoxFuture<'_, Result<ModelsListResponse>>
fn list_models(&self) -> BoxFuture<'_, Result<ModelsListResponse>>
Source§fn image_generate(
&self,
req: CreateImageRequest,
) -> BoxFuture<'_, Result<ImagesResponse>>
fn image_generate( &self, req: CreateImageRequest, ) -> BoxFuture<'_, Result<ImagesResponse>>
Source§fn speech(&self, req: CreateSpeechRequest) -> BoxFuture<'_, Result<Bytes>>
fn speech(&self, req: CreateSpeechRequest) -> BoxFuture<'_, Result<Bytes>>
Source§fn transcribe(
&self,
req: CreateTranscriptionRequest,
) -> BoxFuture<'_, Result<TranscriptionResponse>>
fn transcribe( &self, req: CreateTranscriptionRequest, ) -> BoxFuture<'_, Result<TranscriptionResponse>>
Source§fn moderate(
&self,
req: ModerationRequest,
) -> BoxFuture<'_, Result<ModerationResponse>>
fn moderate( &self, req: ModerationRequest, ) -> BoxFuture<'_, Result<ModerationResponse>>
Source§fn rerank(&self, req: RerankRequest) -> BoxFuture<'_, Result<RerankResponse>>
fn rerank(&self, req: RerankRequest) -> BoxFuture<'_, Result<RerankResponse>>
Source§fn search(&self, req: SearchRequest) -> BoxFuture<'_, Result<SearchResponse>>
fn search(&self, req: SearchRequest) -> BoxFuture<'_, Result<SearchResponse>>
Source§fn ocr(&self, req: OcrRequest) -> BoxFuture<'_, Result<OcrResponse>>
fn ocr(&self, req: OcrRequest) -> BoxFuture<'_, Result<OcrResponse>>
Source§impl LlmClientRaw for DefaultClient
Available on crate features native-http or wasm-http only.
impl LlmClientRaw for DefaultClient
native-http or wasm-http only.Source§fn chat_raw(
&self,
req: ChatCompletionRequest,
) -> BoxFuture<'_, Result<RawExchange<ChatCompletionResponse>>>
fn chat_raw( &self, req: ChatCompletionRequest, ) -> BoxFuture<'_, Result<RawExchange<ChatCompletionResponse>>>
Source§fn chat_stream_raw(
&self,
req: ChatCompletionRequest,
) -> BoxFuture<'_, Result<RawStreamExchange<BoxStream<'static, Result<ChatCompletionChunk>>>>>
fn chat_stream_raw( &self, req: ChatCompletionRequest, ) -> BoxFuture<'_, Result<RawStreamExchange<BoxStream<'static, Result<ChatCompletionChunk>>>>>
Source§fn embed_raw(
&self,
req: EmbeddingRequest,
) -> BoxFuture<'_, Result<RawExchange<EmbeddingResponse>>>
fn embed_raw( &self, req: EmbeddingRequest, ) -> BoxFuture<'_, Result<RawExchange<EmbeddingResponse>>>
Source§fn image_generate_raw(
&self,
req: CreateImageRequest,
) -> BoxFuture<'_, Result<RawExchange<ImagesResponse>>>
fn image_generate_raw( &self, req: CreateImageRequest, ) -> BoxFuture<'_, Result<RawExchange<ImagesResponse>>>
Source§fn transcribe_raw(
&self,
req: CreateTranscriptionRequest,
) -> BoxFuture<'_, Result<RawExchange<TranscriptionResponse>>>
fn transcribe_raw( &self, req: CreateTranscriptionRequest, ) -> BoxFuture<'_, Result<RawExchange<TranscriptionResponse>>>
Source§fn moderate_raw(
&self,
req: ModerationRequest,
) -> BoxFuture<'_, Result<RawExchange<ModerationResponse>>>
fn moderate_raw( &self, req: ModerationRequest, ) -> BoxFuture<'_, Result<RawExchange<ModerationResponse>>>
Source§fn rerank_raw(
&self,
req: RerankRequest,
) -> BoxFuture<'_, Result<RawExchange<RerankResponse>>>
fn rerank_raw( &self, req: RerankRequest, ) -> BoxFuture<'_, Result<RawExchange<RerankResponse>>>
Source§fn search_raw(
&self,
req: SearchRequest,
) -> BoxFuture<'_, Result<RawExchange<SearchResponse>>>
fn search_raw( &self, req: SearchRequest, ) -> BoxFuture<'_, Result<RawExchange<SearchResponse>>>
Source§fn ocr_raw(
&self,
req: OcrRequest,
) -> BoxFuture<'_, Result<RawExchange<OcrResponse>>>
fn ocr_raw( &self, req: OcrRequest, ) -> BoxFuture<'_, Result<RawExchange<OcrResponse>>>
Source§impl ResponseClient for DefaultClient
Available on crate features native-http or wasm-http only.
impl ResponseClient for DefaultClient
native-http or wasm-http only.