Struct OpenAiCompatibleModelProvider
pub struct OpenAiCompatibleModelProvider {
pub alias: String,
pub name: String,
pub base_url: String,
pub credential: Option<String>,
pub auth_header: AuthStyle,
/* private fields */
}Expand description
A model_provider that speaks the OpenAI-compatible chat completions API.
Used by: Venice, Vercel AI Gateway, Cloudflare AI Gateway, Moonshot,
Synthetic, OpenCode Zen, OpenCode Go, Z.AI, GLM, MiniMax, Bedrock, Qianfan, Groq, Mistral, xAI, etc.
Fields§
§alias: String[providers.models.<alias>] key this provider was constructed
under. Used by the Attributable impl so log emissions carry the
real composite (<type>.<alias>) instead of the bare type.
name: String§base_url: String§credential: Option<String>§auth_header: AuthStyleImplementations§
Source§impl OpenAiCompatibleModelProvider
impl OpenAiCompatibleModelProvider
Sourcepub fn builder(alias: &str) -> OpenAiCompatibleBuilder
pub fn builder(alias: &str) -> OpenAiCompatibleBuilder
Entry point for constructing an OpenAI-compatible provider.
Only alias is taken as a positional argument; every other field
is set via labelled chain methods on the returned
OpenAiCompatibleBuilder so call sites remain readable. See
OpenAiCompatibleBuilder::build for the fields that must be
set before calling build().
Trait Implementations§
Source§impl Clone for OpenAiCompatibleModelProvider
impl Clone for OpenAiCompatibleModelProvider
Source§fn clone(&self) -> OpenAiCompatibleModelProvider
fn clone(&self) -> OpenAiCompatibleModelProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ModelProvider for OpenAiCompatibleModelProvider
impl ModelProvider for OpenAiCompatibleModelProvider
Source§fn capabilities(&self) -> ProviderCapabilities
fn capabilities(&self) -> ProviderCapabilities
Query model_provider capabilities.
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn list_models_with_pricing<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_models_with_pricing<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fetch the list of available models with pricing data for this
model_provider. Default delegates to
list_models and returns no
pricing. Concrete providers that receive pricing from their /models
endpoint override this to return enriched data.Source§fn chat_with_system<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
system_prompt: Option<&'life1 str>,
message: &'life2 str,
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn chat_with_system<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
system_prompt: Option<&'life1 str>,
message: &'life2 str,
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
One-shot chat with optional system prompt. See
simple_chat for
the temperature contract.Source§fn chat_with_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn chat_with_history<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Multi-turn conversation. See
simple_chat for the temperature
contract.Source§fn chat_with_tools<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
tools: &'life2 [Value],
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ProviderChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn chat_with_tools<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
tools: &'life2 [Value],
model: &'life3 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ProviderChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Chat with tool definitions for native function calling support.
See
simple_chat for the temperature contract.Source§fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: ProviderChatRequest<'life1>,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ProviderChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: ProviderChatRequest<'life1>,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<ProviderChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Structured chat API for agent loop callers. See
simple_chat for
the temperature contract.Source§fn supports_native_tools(&self) -> bool
fn supports_native_tools(&self) -> bool
Whether model_provider supports native tool calls over API.
Source§fn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Whether model_provider supports streaming responses.
Source§fn supports_streaming_tool_events(&self) -> bool
fn supports_streaming_tool_events(&self) -> bool
Whether model_provider can emit structured tool-call stream events.
Source§fn stream_chat(
&self,
request: ProviderChatRequest<'_>,
model: &str,
temperature: Option<f64>,
options: StreamOptions,
) -> BoxStream<'static, StreamResult<StreamEvent>>
fn stream_chat( &self, request: ProviderChatRequest<'_>, model: &str, temperature: Option<f64>, options: StreamOptions, ) -> BoxStream<'static, StreamResult<StreamEvent>>
Structured streaming chat interface. See
simple_chat for the
temperature contract.Source§fn stream_chat_with_system(
&self,
system_prompt: Option<&str>,
message: &str,
model: &str,
temperature: Option<f64>,
options: StreamOptions,
) -> BoxStream<'static, StreamResult<StreamChunk>>
fn stream_chat_with_system( &self, system_prompt: Option<&str>, message: &str, model: &str, temperature: Option<f64>, options: StreamOptions, ) -> BoxStream<'static, StreamResult<StreamChunk>>
Streaming chat with optional system prompt. See
simple_chat for
the temperature contract.Source§fn stream_chat_with_history(
&self,
messages: &[ChatMessage],
model: &str,
temperature: Option<f64>,
options: StreamOptions,
) -> BoxStream<'static, StreamResult<StreamChunk>>
fn stream_chat_with_history( &self, messages: &[ChatMessage], model: &str, temperature: Option<f64>, options: StreamOptions, ) -> BoxStream<'static, StreamResult<StreamChunk>>
Streaming chat with history. See
simple_chat for the temperature
contract.Source§fn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Warm up the HTTP connection pool.
Source§fn capabilities_for_model(&self, _model: &str) -> ProviderCapabilities
fn capabilities_for_model(&self, _model: &str) -> ProviderCapabilities
Query the effective capabilities for the model that will be dispatched. Read more
Source§fn default_temperature(&self) -> f64
fn default_temperature(&self) -> f64
Family-preferred temperature default. Override per family. Documented
for introspection only; never use to convert
None into a wire value.Source§fn default_max_tokens(&self) -> u32
fn default_max_tokens(&self) -> u32
Max output tokens used when the caller / config doesn’t set one.
Source§fn default_timeout_secs(&self) -> u64
fn default_timeout_secs(&self) -> u64
HTTP timeout (seconds) used when the caller / config doesn’t set one.
Source§fn default_base_url(&self) -> Option<&str>
fn default_base_url(&self) -> Option<&str>
Canonical public API endpoint, when there is one. Returned as a
string slice so model_provider impls can serve from
const &'static strs
without allocations. None = model_provider has no universal endpoint
(local model_providers, auth-less CLIs, user-BYO endpoints).Source§fn default_wire_api(&self) -> &str
fn default_wire_api(&self) -> &str
Wire protocol variant. Either
"responses" (OpenAI Codex-style) or
"chat_completions" (everything else). Providers override to their
native format.Source§fn convert_tools(&self, tools: &[ToolSpec]) -> ToolsPayload
fn convert_tools(&self, tools: &[ToolSpec]) -> ToolsPayload
Convert tool specifications to provider-native format.
Source§fn simple_chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 str,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn simple_chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
message: &'life1 str,
model: &'life2 str,
temperature: Option<f64>,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Simple one-shot chat (single user message, no explicit system prompt).
temperature == None means the field is omitted on the wire.Source§fn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Whether model_provider supports multimodal vision input.
Auto Trait Implementations§
impl Freeze for OpenAiCompatibleModelProvider
impl !RefUnwindSafe for OpenAiCompatibleModelProvider
impl Send for OpenAiCompatibleModelProvider
impl Sync for OpenAiCompatibleModelProvider
impl Unpin for OpenAiCompatibleModelProvider
impl UnsafeUnpin for OpenAiCompatibleModelProvider
impl !UnwindSafe for OpenAiCompatibleModelProvider
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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