Skip to main content

OpenAiCompatibleBuilder

Struct OpenAiCompatibleBuilder 

pub struct OpenAiCompatibleBuilder { /* private fields */ }
Expand description

Typed builder for OpenAiCompatibleModelProvider.

alias (the config key this provider was constructed under) is the only argument passed to OpenAiCompatibleModelProvider::builder. Every other field — including the semantically-required display_name / base_url / auth_style — is set via a labelled chain method so call sites read as prose instead of a comma-counted tuple. build() panics if any of display_name, base_url, or auth_style were omitted; there are no sensible defaults for those.

Implementations§

Source§

impl OpenAiCompatibleBuilder

Source

pub fn display_name(self, name: &str) -> Self

Human-readable display name (e.g. "Groq", "MiniMax"). Surfaced in logs, Attributable output, and the onboarding UI. Required.

Source

pub fn base_url(self, base_url: &str) -> Self

Base URL for the provider’s /chat/completions endpoint. Trailing slashes are stripped so callers need not care whether config supplied them. Required.

Source

pub fn credential(self, credential: Option<&str>) -> Self

Explicit API credential. None (the default) leaves this provider unauthenticated, which is how local LLM servers (Ollama, llama.cpp) are constructed. Whitespace-only inputs are normalized to None so a stray Some(" ") from config cannot produce a bogus Bearer header.

Source

pub fn auth_style(self, style: AuthStyle) -> Self

How this provider expects the API key to be sent. Required.

Source

pub fn vision(self, supports_vision: bool) -> Self

Enable OpenAI-style multimodal (image) inputs on this provider.

Source

pub fn user_agent(self, user_agent: &str) -> Self

Set a custom User-Agent header for outbound requests.

Required by providers whose routing / policy stack keys off the UA string (for example Kimi Code).

Source

pub fn merge_system_into_user(self) -> Self

For providers that reject role: system outright (e.g. MiniMax). Collects all system messages and prepends their content to the first user message; also disables native tool calling because such providers generally reject OpenAI-style tools payloads as well.

Prefer OpenAiCompatibleBuilder::merge_system_into_user_preserving_native when you want the merge behaviour but still want native tool calling (e.g. Bedrock).

Source

pub fn merge_system_into_user_preserving_native(self) -> Self

Merge all system messages into the first user message before sending, preserving native tool calling. Use when the upstream rejects role: system but still accepts OpenAI-style tools payloads (e.g. Bedrock’s Anthropic pass-through).

Source

pub fn without_native_tools(self) -> Self

Disable native tool calling, forcing prompt-guided tool use instead.

Source

pub fn timeout_secs(self, timeout_secs: u64) -> Self

Override the HTTP request timeout for LLM API calls. Values of 0 are ignored (the default 120 s is kept) so a stray Some(0) from config cannot silently disable the safety timeout.

Source

pub fn extra_headers(self, headers: HashMap<String, String>) -> Self

Set extra HTTP headers to include in all API requests.

Source

pub fn reasoning_effort(self, reasoning_effort: Option<String>) -> Self

Set reasoning effort for GPT-5/Codex-compatible chat-completions APIs.

Source

pub fn without_assistant_reasoning_replay(self) -> Self

Disable replay of stored assistant reasoning on outbound assistant history messages.

Source

pub fn api_path(self, api_path: Option<String>) -> Self

Set a custom API path suffix for this model_provider.

Source

pub fn max_tokens(self, max_tokens: Option<u32>) -> Self

Set the maximum output tokens for API requests.

Source

pub fn models_dev_key(self, key: &str) -> Self

Set the models.dev catalog key for this model_provider.

Source

pub fn openrouter_vendor_prefix(self, prefix: &str) -> Self

Set the OpenRouter vendor prefix for this model_provider.

Source

pub fn local_model_tool_sanitize(self) -> Self

Opt into per-model conservative tool-schema sanitization.

Source

pub fn public_model_listing(self) -> Self

Treat the /models endpoint as publicly accessible.

Source

pub fn tls_ca_cert_path(self, path: &str) -> Self

Path to a PEM-encoded custom CA certificate for TLS connections. The file is read once at Self::build time; failures are logged at WARN and TLS falls back to the system trust store.

Source

pub fn extra_body(self, extra: Value) -> Self

Inject extra JSON fields into every API request body.

Source

pub fn auth_profile( self, model_provider: &str, auth_service: AuthService, profile_override: Option<String>, ) -> Self

Use a stored auth profile as a bearer credential when no explicit api_key was configured on this provider entry.

Source

pub fn build(self) -> OpenAiCompatibleModelProvider

Finalize the builder into a ready provider. Every optional construction value must be set on this builder; the returned provider has no post-construction mutators.

§Panics

Panics if Self::display_name, Self::base_url, or Self::auth_style was not called — those three fields carry no sensible default and every real call site sets them.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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, 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,