Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

A handle to one SIE server.

Cloning is cheap and shares the underlying connection pool, so a Client can be stored once and used from every task.

Implementations§

Source§

impl Client

Source

pub fn batches(&self) -> Batches

Operations on offline batches.

Source§

impl Client

Source

pub fn connections(&self) -> Connections

Operations on stored data-store credentials.

Source§

impl Client

Source

pub fn encode( &self, model: impl Into<String>, items: impl IntoIterator<Item = Item>, ) -> EncodeRequest

Embed one or more items.

Source

pub fn score( &self, model: impl Into<String>, query: Item, items: impl IntoIterator<Item = Item>, ) -> ScoreRequest

Score a query against a set of candidates.

Source

pub fn extract( &self, model: impl Into<String>, items: impl IntoIterator<Item = Item>, ) -> ExtractRequest

Extract structure from one or more items.

Source§

impl Client

Source

pub fn files(&self) -> Files

Operations on uploaded files.

Source§

impl Client

Source

pub async fn estimate( &self, endpoint: &str, request: Value, ) -> Result<CostEstimate>

Estimate the cost of a request before sending it.

endpoint is the absolute path the request would be sent to, and request is the body it would carry.

Source

pub fn generate( &self, model: impl Into<String>, prompt: impl Into<String>, max_new_tokens: u32, ) -> GenerateRequest

Generate text with the native endpoint.

Source

pub fn chat( &self, model: impl Into<String>, messages: impl IntoIterator<Item = ChatMessage>, ) -> ChatRequest

Generate a chat completion.

Source

pub fn responses( &self, model: impl Into<String>, input: ResponseInput, ) -> ResponsesRequest

Generate a response through the Responses API.

Source§

impl Client

Source

pub fn jobs(&self) -> Jobs

Operations on batch jobs.

Source§

impl Client

Source

pub async fn list_models(&self) -> Result<Vec<ModelInfo>>

Every model the server knows about.

Source

pub async fn get_model(&self, model: &str) -> Result<ModelInfo>

Details for one model.

Source

pub async fn health(&self) -> Result<HealthResponse>

Health, from either a gateway or a standalone worker.

A gateway answers /health with the whole cluster’s state. A worker running on its own has no such view: it serves the Kubernetes-style /healthz probe, which is plain text, so its reply is reported as a worker with that status and nothing else.

Source

pub async fn get_capacity(&self, gpu: Option<&str>) -> Result<CapacityInfo>

Cluster capacity, optionally narrowed to one GPU type.

Requires a gateway: a worker’s /health describes only itself.

Source

pub async fn wait_for_capacity( &self, gpu: &str, model: Option<&str>, timeout: Option<Duration>, poll_interval: Duration, ) -> Result<CapacityInfo>

Block until a GPU type has capacity.

With model, this warms the model as well: it issues one small encode with capacity waiting enabled, which triggers both scale-up and model loading, then reports the resulting capacity. Without it, /health is polled until a worker appears.

Source§

impl Client

Source

pub fn pools(&self) -> Pools

Operations on worker pools.

Source§

impl Client

Source

pub async fn watch(&self, mode: WatchMode) -> Result<ChunkStream<StatusMessage>>

Stream status broadcasts until the connection closes.

With WatchMode::Auto, /health is probed once to decide which endpoint to open.

Source§

impl Client

Source

pub fn new(base_url: impl AsRef<str>) -> Result<Self>

A client with default settings.

Source

pub fn builder(base_url: impl AsRef<str>) -> ClientBuilder

Start configuring a client.

Source

pub fn base_url(&self) -> &str

The server root, always with a trailing slash.

Source

pub fn default_options(&self) -> &RequestOptions

Per-call defaults this client applies when a request builder does not override them.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more