pub struct Client<Ext = Nothing, H = Client> { /* private fields */ }Expand description
Generic provider client shared by Rig provider integrations.
Ext stores provider-specific behavior such as URL construction, request
customization, and capabilities. H is the HTTP backend and defaults to
reqwest::Client.
Implementations§
Source§impl<Ext> Client<Ext, Client>
new is pinned to H = reqwest::Client so the call site infers without an explicit H
annotation. Callers who want a different backend should go through Client::builder and
chain ClientBuilder::http_client before ClientBuilder::build.
impl<Ext> Client<Ext, Client>
new is pinned to H = reqwest::Client so the call site infers without an explicit H
annotation. Callers who want a different backend should go through Client::builder and
chain ClientBuilder::http_client before ClientBuilder::build.
Source§impl<Ext, H> Client<Ext, H>
impl<Ext, H> Client<Ext, H>
Source§impl<Ext> Client<Ext, Client>
builder() is anchored on Client<Ext, reqwest::Client> purely as an inference hook so that
provider::Client::builder() resolves without a H annotation. The returned builder itself
has H = Missing, accurately reflecting that no backend has been chosen yet; the eventual
Client produced by build() may end up with any HTTP backend depending on whether
ClientBuilder::http_client was called.
impl<Ext> Client<Ext, Client>
builder() is anchored on Client<Ext, reqwest::Client> purely as an inference hook so that
provider::Client::builder() resolves without a H annotation. The returned builder itself
has H = Missing, accurately reflecting that no backend has been chosen yet; the eventual
Client produced by build() may end up with any HTTP backend depending on whether
ClientBuilder::http_client was called.
Source§impl<Ext, H> Client<Ext, H>where
Ext: Provider,
impl<Ext, H> Client<Ext, H>where
Ext: Provider,
Sourcepub fn post<S>(&self, path: S) -> Result<Builder>
pub fn post<S>(&self, path: S) -> Result<Builder>
Build a provider-customized POST request for a regular HTTP endpoint.
Sourcepub fn post_sse<S>(&self, path: S) -> Result<Builder>
pub fn post_sse<S>(&self, path: S) -> Result<Builder>
Build a provider-customized POST request for an SSE endpoint.
Source§impl<H> Client<ChatGPTExt, H>
impl<H> Client<ChatGPTExt, H>
Source§impl<T> Client<CohereExt, T>
impl<T> Client<CohereExt, T>
pub fn embeddings<D: Embed>( &self, model: impl Into<String>, input_type: &str, ) -> EmbeddingsBuilder<EmbeddingModel<T>, D>
Sourcepub fn embedding_model(
&self,
model: impl Into<String>,
input_type: &str,
) -> EmbeddingModel<T>
pub fn embedding_model( &self, model: impl Into<String>, input_type: &str, ) -> EmbeddingModel<T>
Note: default embedding dimension of 0 will be used if model is not known.
If this is the case, it’s better to use function embedding_model_with_ndims
Sourcepub fn embedding_model_with_ndims(
&self,
model: impl Into<String>,
input_type: &str,
ndims: usize,
) -> EmbeddingModel<T>
pub fn embedding_model_with_ndims( &self, model: impl Into<String>, input_type: &str, ndims: usize, ) -> EmbeddingModel<T>
Create an embedding model with the given name and the number of dimensions in the embedding generated by the model.
Source§impl<H> Client<CopilotExt, H>
impl<H> Client<CopilotExt, H>
Source§impl<H> Client<GeminiExt, H>
impl<H> Client<GeminiExt, H>
Sourcepub fn interactions_api(self) -> InteractionsClient<H>
pub fn interactions_api(self) -> InteractionsClient<H>
Create an Interactions API client from this GenerateContent client.
Source§impl<H> Client<GeminiInteractionsExt, H>
impl<H> Client<GeminiInteractionsExt, H>
Sourcepub fn generate_content_api(self) -> Client<H>
pub fn generate_content_api(self) -> Client<H>
Create a GenerateContent API client from this Interactions client.
Source§impl<T> Client<GeminiInteractionsExt, T>
impl<T> Client<GeminiInteractionsExt, T>
Sourcepub async fn create_interaction(
&self,
request: CreateInteractionRequest,
) -> Result<Interaction, CompletionError>
pub async fn create_interaction( &self, request: CreateInteractionRequest, ) -> Result<Interaction, CompletionError>
Create a new interaction and return the raw response payload.
Sourcepub async fn get_interaction(
&self,
interaction_id: impl AsRef<str>,
) -> Result<Interaction, CompletionError>
pub async fn get_interaction( &self, interaction_id: impl AsRef<str>, ) -> Result<Interaction, CompletionError>
Fetch an interaction by ID (useful for polling background tasks).
Sourcepub async fn stream_interaction_events(
&self,
request: CreateInteractionRequest,
) -> Result<InteractionEventStream, CompletionError>
pub async fn stream_interaction_events( &self, request: CreateInteractionRequest, ) -> Result<InteractionEventStream, CompletionError>
Start an interaction and stream raw SSE events.
Sourcepub async fn stream_interaction_events_by_id(
&self,
interaction_id: impl AsRef<str>,
last_event_id: Option<&str>,
) -> Result<InteractionEventStream, CompletionError>
pub async fn stream_interaction_events_by_id( &self, interaction_id: impl AsRef<str>, last_event_id: Option<&str>, ) -> Result<InteractionEventStream, CompletionError>
Resume an interaction stream by ID and optional last event ID.
Source§impl Client<LlamafileExt>
impl Client<LlamafileExt>
Sourcepub fn from_url(base_url: &str) -> ProviderClientResult<Self>
pub fn from_url(base_url: &str) -> ProviderClientResult<Self>
Create a client pointing at the given llamafile base URL
(e.g. http://localhost:8080).
Source§impl<T> Client<MiraExt, T>where
T: HttpClientExt + 'static,
impl<T> Client<MiraExt, T>where
T: HttpClientExt + 'static,
Source§impl<H> Client<OpenAIResponsesExt, H>
impl<H> Client<OpenAIResponsesExt, H>
Sourcepub fn with_system_instructions_placement(
self,
placement: SystemInstructionsPlacement,
) -> Self
pub fn with_system_instructions_placement( self, placement: SystemInstructionsPlacement, ) -> Self
Sets where Rig system instructions are placed in Responses requests for
every completion model created from this client. Models capture the
placement when they are created, so models built before this call are
unaffected. See SystemInstructionsPlacement for when each placement applies.
Sourcepub fn with_system_instructions_as_messages(self) -> Self
pub fn with_system_instructions_as_messages(self) -> Self
Sends Rig system instructions as system messages in input instead of
as top-level Responses API instructions for every completion model
created from this client. Models built before this call are unaffected.
OpenAI’s Responses API supports instructions, and Rig uses it by
default. Use this compatibility fallback for OpenAI-compatible providers
that reject or ignore top-level instructions.
Sourcepub fn completions_api(self) -> CompletionsClient<H>
pub fn completions_api(self) -> CompletionsClient<H>
Create a Completions API client from this Responses API client. Useful for switching to the traditional Chat Completions API.
Source§impl Client<OpenAIResponsesExt>
impl Client<OpenAIResponsesExt>
Sourcepub fn responses_websocket_builder(
&self,
model: impl Into<String>,
) -> ResponsesWebSocketSessionBuilder
Available on crate feature websocket and non-target_family=wasm only.
pub fn responses_websocket_builder( &self, model: impl Into<String>, ) -> ResponsesWebSocketSessionBuilder
websocket and non-target_family=wasm only.WebSocket mode currently uses a native tokio-tungstenite transport and does
not reuse custom HttpClientExt backends, so this API is only exposed for the
default reqwest::Client transport.
Sourcepub async fn responses_websocket(
&self,
model: impl Into<String>,
) -> Result<ResponsesWebSocketSession, CompletionError>
Available on crate feature websocket and non-target_family=wasm only.
pub async fn responses_websocket( &self, model: impl Into<String>, ) -> Result<ResponsesWebSocketSession, CompletionError>
websocket and non-target_family=wasm only.This API is OpenAI-specific and only available on non-wasm targets in rig-core.
Source§impl<H> Client<OpenAICompletionsExt, H>
impl<H> Client<OpenAICompletionsExt, H>
Sourcepub fn responses_api(self) -> Client<H>
pub fn responses_api(self) -> Client<H>
Create a Responses API client from this Completions API client. Useful for switching to the newer Responses API. A system-instructions placement configured before switching to the Completions API is restored.
Trait Implementations§
Source§impl<M, Ext, H> AudioGenerationClient for Client<Ext, H>
Available on crate feature audio only.
impl<M, Ext, H> AudioGenerationClient for Client<Ext, H>
audio only.Source§type AudioGenerationModel = M
type AudioGenerationModel = M
Source§fn audio_generation_model(
&self,
model: impl Into<String>,
) -> Self::AudioGenerationModel
fn audio_generation_model( &self, model: impl Into<String>, ) -> Self::AudioGenerationModel
Source§impl<M, Ext, H> CompletionClient for Client<Ext, H>
impl<M, Ext, H> CompletionClient for Client<Ext, H>
Source§type CompletionModel = M
type CompletionModel = M
Source§fn completion_model(&self, model: impl Into<String>) -> Self::CompletionModel
fn completion_model(&self, model: impl Into<String>) -> Self::CompletionModel
Source§impl<M, Ext, H> EmbeddingsClient for Client<Ext, H>
impl<M, Ext, H> EmbeddingsClient for Client<Ext, H>
Source§type EmbeddingModel = M
type EmbeddingModel = M
Source§fn embedding_model(&self, model: impl Into<String>) -> Self::EmbeddingModel
fn embedding_model(&self, model: impl Into<String>) -> Self::EmbeddingModel
Source§fn embedding_model_with_ndims(
&self,
model: impl Into<String>,
ndims: usize,
) -> Self::EmbeddingModel
fn embedding_model_with_ndims( &self, model: impl Into<String>, ndims: usize, ) -> Self::EmbeddingModel
Source§fn embeddings<D: Embed>(
&self,
model: impl Into<String>,
) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
fn embeddings<D: Embed>( &self, model: impl Into<String>, ) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
Source§fn embeddings_with_ndims<D: Embed>(
&self,
model: &str,
ndims: usize,
) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
fn embeddings_with_ndims<D: Embed>( &self, model: &str, ndims: usize, ) -> EmbeddingsBuilder<Self::EmbeddingModel, D>
Source§impl<Ext, H> HttpClientExt for Client<Ext, H>
impl<Ext, H> HttpClientExt for Client<Ext, H>
Source§fn send<T, U>(
&self,
req: Request<T>,
) -> impl Future<Output = Result<Response<LazyBody<U>>>> + WasmCompatSend + 'static
fn send<T, U>( &self, req: Request<T>, ) -> impl Future<Output = Result<Response<LazyBody<U>>>> + WasmCompatSend + 'static
Source§fn send_multipart<U>(
&self,
req: Request<MultipartForm>,
) -> impl Future<Output = Result<Response<LazyBody<U>>>> + WasmCompatSend + 'static
fn send_multipart<U>( &self, req: Request<MultipartForm>, ) -> impl Future<Output = Result<Response<LazyBody<U>>>> + WasmCompatSend + 'static
Source§fn send_streaming<T>(
&self,
req: Request<T>,
) -> impl Future<Output = Result<StreamingResponse>> + WasmCompatSend
fn send_streaming<T>( &self, req: Request<T>, ) -> impl Future<Output = Result<StreamingResponse>> + WasmCompatSend
bytes::Bytes.)Source§impl<M, Ext, H> ImageGenerationClient for Client<Ext, H>
Available on crate feature image only.
impl<M, Ext, H> ImageGenerationClient for Client<Ext, H>
image only.Source§type ImageGenerationModel = M
type ImageGenerationModel = M
Source§fn image_generation_model(
&self,
model: impl Into<String>,
) -> Self::ImageGenerationModel
fn image_generation_model( &self, model: impl Into<String>, ) -> Self::ImageGenerationModel
Source§fn custom_image_generation_model(
&self,
model: impl Into<String>,
) -> Self::ImageGenerationModel
fn custom_image_generation_model( &self, model: impl Into<String>, ) -> Self::ImageGenerationModel
Source§impl<M, Ext, H> ModelListingClient for Client<Ext, H>where
Ext: Capabilities<H, ModelListing = Capable<M>> + Clone,
M: ModelLister<H, Client = Self> + WasmCompatSend + WasmCompatSync + Clone + 'static,
H: WasmCompatSend + WasmCompatSync + Clone,
impl<M, Ext, H> ModelListingClient for Client<Ext, H>where
Ext: Capabilities<H, ModelListing = Capable<M>> + Clone,
M: ModelLister<H, Client = Self> + WasmCompatSend + WasmCompatSync + Clone + 'static,
H: WasmCompatSend + WasmCompatSync + Clone,
Source§fn list_models(
&self,
) -> impl Future<Output = Result<ModelList, ModelListingError>> + WasmCompatSend
fn list_models( &self, ) -> impl Future<Output = Result<ModelList, ModelListingError>> + WasmCompatSend
Source§impl<M, Ext, H> RerankingClient for Client<Ext, H>
impl<M, Ext, H> RerankingClient for Client<Ext, H>
Source§type RerankModel = M
type RerankModel = M
RerankModel used by the Client.Source§fn rerank_model(&self, model: impl Into<String>) -> Self::RerankModel
fn rerank_model(&self, model: impl Into<String>) -> Self::RerankModel
Source§impl<M, Ext, H> TranscriptionClient for Client<Ext, H>where
Ext: Capabilities<H, Transcription = Capable<M>>,
M: TranscriptionModel<Client = Self> + WasmCompatSend,
impl<M, Ext, H> TranscriptionClient for Client<Ext, H>where
Ext: Capabilities<H, Transcription = Capable<M>>,
M: TranscriptionModel<Client = Self> + WasmCompatSend,
Source§type TranscriptionModel = M
type TranscriptionModel = M
Source§fn transcription_model(
&self,
model: impl Into<String>,
) -> Self::TranscriptionModel
fn transcription_model( &self, model: impl Into<String>, ) -> Self::TranscriptionModel
Source§impl<Ext, H> VerifyClient for Client<Ext, H>
impl<Ext, H> VerifyClient for Client<Ext, H>
Auto Trait Implementations§
impl<Ext, H> Freeze for Client<Ext, H>
impl<Ext, H> RefUnwindSafe for Client<Ext, H>where
H: RefUnwindSafe,
Ext: RefUnwindSafe,
impl<Ext, H> Send for Client<Ext, H>
impl<Ext, H> Sync for Client<Ext, H>
impl<Ext, H> Unpin for Client<Ext, H>
impl<Ext, H> UnsafeUnpin for Client<Ext, H>where
H: UnsafeUnpin,
Ext: UnsafeUnpin,
impl<Ext, H> UnwindSafe for Client<Ext, H>where
H: UnwindSafe,
Ext: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more