Skip to main content

OpenAiCompatibleModelProvider

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: AuthStyle

Implementations§

Source§

impl OpenAiCompatibleModelProvider

Source

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 Attributable for OpenAiCompatibleModelProvider

Source§

fn role(&self) -> Role

Source§

fn alias(&self) -> &str

Source§

impl Clone for OpenAiCompatibleModelProvider

Source§

fn clone(&self) -> OpenAiCompatibleModelProvider

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

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

Performs copy-assignment from source. Read more
Source§

impl ModelProvider for OpenAiCompatibleModelProvider

Source§

fn capabilities(&self) -> ProviderCapabilities

Query model_provider capabilities.
Source§

fn list_models<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, OpenAiCompatibleModelProvider: 'async_trait,

Source§

fn list_models_with_pricing<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, OpenAiCompatibleModelProvider: '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, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, OpenAiCompatibleModelProvider: '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, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, OpenAiCompatibleModelProvider: '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<ChatResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, OpenAiCompatibleModelProvider: '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: ChatRequest<'life1>, model: &'life2 str, temperature: Option<f64>, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, OpenAiCompatibleModelProvider: 'async_trait,

Structured chat API for agent loop callers. See simple_chat for the temperature contract.
Source§

fn supports_native_tools(&self) -> bool

Whether model_provider supports native tool calls over API.
Source§

fn supports_streaming(&self) -> bool

Whether model_provider supports streaming responses.
Source§

fn supports_streaming_tool_events(&self) -> bool

Whether model_provider can emit structured tool-call stream events.
Source§

fn stream_chat( &self, request: ChatRequest<'_>, model: &str, temperature: Option<f64>, options: StreamOptions, ) -> Pin<Box<dyn Stream<Item = Result<StreamEvent, StreamError>> + Send>>

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, ) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, StreamError>> + Send>>

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, ) -> Pin<Box<dyn Stream<Item = Result<StreamChunk, StreamError>> + Send>>

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<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, OpenAiCompatibleModelProvider: 'async_trait,

Warm up the HTTP connection pool.
Source§

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

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

Max output tokens used when the caller / config doesn’t set one.
Source§

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>

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

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

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,

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

Whether model_provider supports multimodal vision input.

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<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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

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

§

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