pub struct OpenAiCompatible { /* private fields */ }Expand description
Generic OpenAI-compatible model provider. No default base URL — always
construct with OpenAiCompatible::new.
Implementations§
Source§impl OpenAiCompatible
impl OpenAiCompatible
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
Create a client targeting the given base URL (e.g. http://localhost:8000).
Sourcepub fn with_base_url(self, url: impl Into<String>) -> Self
pub fn with_base_url(self, url: impl Into<String>) -> Self
Override the base URL set at construction.
Sourcepub fn with_model(self, name: impl Into<String>) -> Self
pub fn with_model(self, name: impl Into<String>) -> Self
Set the model name sent in the request body.
Sourcepub fn with_api_key(self, key: impl Into<String>) -> Self
pub fn with_api_key(self, key: impl Into<String>) -> Self
Set the API key / bearer token, if the server requires one.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set a custom timeout for HTTP requests.
Sourcepub fn with_max_retries(self, retries: u32) -> Self
pub fn with_max_retries(self, retries: u32) -> Self
Set the maximum number of retries for transient (429 / 5xx) errors on the initial request (default: 3).
Sourcepub fn allow_plaintext_api_key(self) -> Self
pub fn allow_plaintext_api_key(self) -> Self
Opts back into warn-and-send for an API key sent over a plaintext
http:// base URL (default: hard error). Only use this for a
genuinely local, unauthenticated-but-keyed server.
Sourcepub fn with_extra_field(self, key: impl Into<String>, value: Value) -> Self
pub fn with_extra_field(self, key: impl Into<String>, value: Value) -> Self
Add an arbitrary top-level field to every chat request body, for
server-specific sampling parameters this generic client doesn’t know
about by name (e.g. vLLM’s repetition_penalty).
Trait Implementations§
Source§impl Debug for OpenAiCompatible
impl Debug for OpenAiCompatible
Source§impl Model for OpenAiCompatible
impl Model for OpenAiCompatible
Source§async fn generate(&self, request: &ChatRequest) -> Result<ChatResponse>
async fn generate(&self, request: &ChatRequest) -> Result<ChatResponse>
Source§async fn generate_stream(&self, request: &ChatRequest) -> Result<ResponseStream>
async fn generate_stream(&self, request: &ChatRequest) -> Result<ResponseStream>
Auto Trait Implementations§
impl !Freeze for OpenAiCompatible
impl !RefUnwindSafe for OpenAiCompatible
impl !UnwindSafe for OpenAiCompatible
impl Send for OpenAiCompatible
impl Sync for OpenAiCompatible
impl Unpin for OpenAiCompatible
impl UnsafeUnpin for OpenAiCompatible
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> ErasedModel for Twhere
T: Model,
impl<T> ErasedModel for Twhere
T: Model,
Source§fn generate_erased<'a>(
&'a self,
request: &'a ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, DaimonError>> + Send + 'a>>
fn generate_erased<'a>( &'a self, request: &'a ChatRequest, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, DaimonError>> + Send + 'a>>
Model::generate.Source§fn generate_stream_erased<'a>(
&'a self,
request: &'a ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, DaimonError>> + Send>>, DaimonError>> + Send + 'a>>
fn generate_stream_erased<'a>( &'a self, request: &'a ChatRequest, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, DaimonError>> + Send>>, DaimonError>> + Send + 'a>>
Model::generate_stream.Source§fn model_id_erased(&self) -> &str
fn model_id_erased(&self) -> &str
Model::model_id.