pub struct Client { /* private fields */ }Expand description
Client for sending AI requests to supported providers.
Construct with:
-
ClientBuilder::default()followed by.build(), or -
Client::builder(), which is equivalent toClientBuilder::default().
Implementations§
Source§impl Client
High-level client APIs.
impl Client
High-level client APIs.
Sourcepub async fn all_model_names(
&self,
adapter_kind: AdapterKind,
provider_config: impl Into<ProviderConfig>,
) -> Result<Vec<String>>
pub async fn all_model_names( &self, adapter_kind: AdapterKind, provider_config: impl Into<ProviderConfig>, ) -> Result<Vec<String>>
Lists model names for the given adapter.
Notes:
-
Non-Ollama adapters use a static list.
-
Ollama queries the default host (http://localhost:11434/v1/).
-
May evolve to accept a custom endpoint.
-
Accepts
ProviderConfigor compatible values to override endpoint and auth. -
For most adapters, names also drive AdapterKind detection (see
AdapterKind). -
Adapters should filter non-chat models until more skills are supported. Future:
model_names(adapter_kind, Option<&[Skill]>).
Sourcepub fn adapter_kind(&self) -> Option<AdapterKind>
pub fn adapter_kind(&self) -> Option<AdapterKind>
Returns the bound AdapterKind for this Client, if any.
Set via ClientBuilder::with_adapter_kind at construction
time — None for Clients that did not opt into the bound
shape and still use per-call model-name inference. Useful for
callers that want to introspect a Client without tracking the
provider in parallel state.
Sourcepub fn default_model(&self, model_name: &str) -> Result<ModelIden>
pub fn default_model(&self, model_name: &str) -> Result<ModelIden>
Builds a ModelIden by inferring AdapterKind from the model name.
Sourcepub async fn resolve_model_iden(&self, model_name: &str) -> Result<ModelIden>
👎Deprecated: use client.resolve_service_target(model_name)
pub async fn resolve_model_iden(&self, model_name: &str) -> Result<ModelIden>
use client.resolve_service_target(model_name)
Deprecated: use Client::resolve_service_target.
Sourcepub async fn resolve_service_target(
&self,
model: impl Into<ModelSpec>,
) -> Result<ServiceTarget>
pub async fn resolve_service_target( &self, model: impl Into<ModelSpec>, ) -> Result<ServiceTarget>
Resolves the service target (endpoint, auth, and model) for the given model.
Accepts any type that implements Into<ModelSpec>:
&strorString: Model name with full inferenceModelIden: Explicit adapter, resolves auth/endpointServiceTarget: Uses directly, bypasses model mapping and auth resolution
Sourcepub async fn exec_chat(
&self,
model: impl Into<ModelSpec>,
chat_req: ChatRequest,
options: Option<&ChatOptions>,
) -> Result<ChatResponse>
pub async fn exec_chat( &self, model: impl Into<ModelSpec>, chat_req: ChatRequest, options: Option<&ChatOptions>, ) -> Result<ChatResponse>
Sends a chat request and returns the full response.
Accepts any type that implements Into<ModelSpec>:
&strorString: Model name with full inferenceModelIden: Explicit adapter, resolves auth/endpointServiceTarget: Uses directly, bypasses model mapping and auth resolution
Sourcepub async fn exec_chat_stream(
&self,
model: impl Into<ModelSpec>,
chat_req: ChatRequest,
options: Option<&ChatOptions>,
) -> Result<ChatStreamResponse>
pub async fn exec_chat_stream( &self, model: impl Into<ModelSpec>, chat_req: ChatRequest, options: Option<&ChatOptions>, ) -> Result<ChatStreamResponse>
Streams a chat response.
Accepts any type that implements Into<ModelSpec>:
&strorString: Model name with full inferenceModelIden: Explicit adapter, resolves auth/endpointServiceTarget: Uses directly, bypasses model mapping and auth resolution
Sourcepub async fn embed(
&self,
model: impl Into<ModelSpec>,
input: impl Into<String>,
options: Option<&EmbedOptions>,
) -> Result<EmbedResponse>
pub async fn embed( &self, model: impl Into<ModelSpec>, input: impl Into<String>, options: Option<&EmbedOptions>, ) -> Result<EmbedResponse>
Creates embeddings for a single input string.
Accepts any type that implements Into<ModelSpec> for the model parameter.
Sourcepub async fn embed_batch(
&self,
model: impl Into<ModelSpec>,
inputs: Vec<String>,
options: Option<&EmbedOptions>,
) -> Result<EmbedResponse>
pub async fn embed_batch( &self, model: impl Into<ModelSpec>, inputs: Vec<String>, options: Option<&EmbedOptions>, ) -> Result<EmbedResponse>
Creates embeddings for multiple input strings.
Accepts any type that implements Into<ModelSpec> for the model parameter.
Sourcepub async fn exec_embed(
&self,
model: impl Into<ModelSpec>,
embed_req: EmbedRequest,
options: Option<&EmbedOptions>,
) -> Result<EmbedResponse>
pub async fn exec_embed( &self, model: impl Into<ModelSpec>, embed_req: EmbedRequest, options: Option<&EmbedOptions>, ) -> Result<EmbedResponse>
Sends an embedding request and returns the response.
Accepts any type that implements Into<ModelSpec>:
&strorString: Model name with full inferenceModelIden: Explicit adapter, resolves auth/endpointServiceTarget: Uses directly, bypasses model mapping and auth resolution