pub struct Client {
pub http_client: Client,
pub api_base: String,
pub api_key: String,
pub user_agent: Option<String>,
pub x_title: Option<String>,
pub referer: Option<String>,
}Expand description
HTTP client for communicating with the OpenRouter API.
Fields§
§http_client: ClientThe underlying HTTP client.
api_base: StringBase URL for the OpenRouter API.
api_key: StringAPI key for authentication with OpenRouter.
user_agent: Option<String>Optional User-Agent header value.
x_title: Option<String>Optional X-Title header value.
referer: Option<String>Optional Referer header value (sent as both referer and http-referer).
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
http_client: Client,
api_base: String,
api_key: String,
user_agent: Option<String>,
x_title: Option<String>,
referer: Option<String>,
) -> Self
pub fn new( http_client: Client, api_base: String, api_key: String, user_agent: Option<String>, x_title: Option<String>, referer: Option<String>, ) -> Self
Creates a new OpenRouter client.
Sourcepub fn create_streaming_for_chat(
&self,
id: String,
byok: Option<&str>,
cost_multiplier: Decimal,
first_chunk_timeout: Duration,
other_chunk_timeout: Duration,
ensemble_llm: &EnsembleLlm,
request: &ChatCompletionCreateParams,
) -> impl Stream<Item = Result<ChatCompletionChunk, Error>> + Send + 'static
pub fn create_streaming_for_chat( &self, id: String, byok: Option<&str>, cost_multiplier: Decimal, first_chunk_timeout: Duration, other_chunk_timeout: Duration, ensemble_llm: &EnsembleLlm, request: &ChatCompletionCreateParams, ) -> impl Stream<Item = Result<ChatCompletionChunk, Error>> + Send + 'static
Creates a streaming chat completion request.
Transforms the request using the Ensemble LLM’s configuration and returns a stream of chat completion chunks.
Sourcepub fn create_streaming_for_vector(
&self,
id: String,
byok: Option<&str>,
cost_multiplier: Decimal,
first_chunk_timeout: Duration,
other_chunk_timeout: Duration,
ensemble_llm: &EnsembleLlm,
request: &VectorCompletionCreateParams,
vector_pfx_indices: &[(String, usize)],
) -> impl Stream<Item = Result<ChatCompletionChunk, Error>> + Send + 'static
pub fn create_streaming_for_vector( &self, id: String, byok: Option<&str>, cost_multiplier: Decimal, first_chunk_timeout: Duration, other_chunk_timeout: Duration, ensemble_llm: &EnsembleLlm, request: &VectorCompletionCreateParams, vector_pfx_indices: &[(String, usize)], ) -> impl Stream<Item = Result<ChatCompletionChunk, Error>> + Send + 'static
Creates a streaming chat completion for LLM voting in vector completions.
The LLM sees responses labeled with prefix keys (e.g., `A`) and responds
with its choice. The vector_pfx_indices maps the prefix keys shown to the LLM
to the indices of the responses in the original request.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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
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> 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