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
impl OpenAiCompatibleBuilder
Sourcepub fn display_name(self, name: &str) -> Self
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.
Sourcepub fn base_url(self, base_url: &str) -> Self
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.
Sourcepub fn credential(self, credential: Option<&str>) -> Self
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.
Sourcepub fn auth_style(self, style: AuthStyle) -> Self
pub fn auth_style(self, style: AuthStyle) -> Self
How this provider expects the API key to be sent. Required.
Sourcepub fn vision(self, supports_vision: bool) -> Self
pub fn vision(self, supports_vision: bool) -> Self
Enable OpenAI-style multimodal (image) inputs on this provider.
Sourcepub fn user_agent(self, user_agent: &str) -> Self
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).
Sourcepub fn merge_system_into_user(self) -> Self
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).
Sourcepub fn merge_system_into_user_preserving_native(self) -> Self
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).
Sourcepub fn without_native_tools(self) -> Self
pub fn without_native_tools(self) -> Self
Disable native tool calling, forcing prompt-guided tool use instead.
Sourcepub fn timeout_secs(self, timeout_secs: u64) -> Self
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.
Sourcepub fn extra_headers(self, headers: HashMap<String, String>) -> Self
pub fn extra_headers(self, headers: HashMap<String, String>) -> Self
Set extra HTTP headers to include in all API requests.
Sourcepub fn reasoning_effort(self, reasoning_effort: Option<String>) -> Self
pub fn reasoning_effort(self, reasoning_effort: Option<String>) -> Self
Set reasoning effort for GPT-5/Codex-compatible chat-completions APIs.
Sourcepub fn without_assistant_reasoning_replay(self) -> Self
pub fn without_assistant_reasoning_replay(self) -> Self
Disable replay of stored assistant reasoning on outbound assistant history messages.
Sourcepub fn api_path(self, api_path: Option<String>) -> Self
pub fn api_path(self, api_path: Option<String>) -> Self
Set a custom API path suffix for this model_provider.
Sourcepub fn max_tokens(self, max_tokens: Option<u32>) -> Self
pub fn max_tokens(self, max_tokens: Option<u32>) -> Self
Set the maximum output tokens for API requests.
Sourcepub fn models_dev_key(self, key: &str) -> Self
pub fn models_dev_key(self, key: &str) -> Self
Set the models.dev catalog key for this model_provider.
Sourcepub fn openrouter_vendor_prefix(self, prefix: &str) -> Self
pub fn openrouter_vendor_prefix(self, prefix: &str) -> Self
Set the OpenRouter vendor prefix for this model_provider.
Sourcepub fn local_model_tool_sanitize(self) -> Self
pub fn local_model_tool_sanitize(self) -> Self
Opt into per-model conservative tool-schema sanitization.
Sourcepub fn public_model_listing(self) -> Self
pub fn public_model_listing(self) -> Self
Treat the /models endpoint as publicly accessible.
Sourcepub fn tls_ca_cert_path(self, path: &str) -> Self
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.
Sourcepub fn extra_body(self, extra: Value) -> Self
pub fn extra_body(self, extra: Value) -> Self
Inject extra JSON fields into every API request body.
Sourcepub fn auth_profile(
self,
model_provider: &str,
auth_service: AuthService,
profile_override: Option<String>,
) -> Self
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.
Sourcepub fn build(self) -> OpenAiCompatibleModelProvider
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§
impl Freeze for OpenAiCompatibleBuilder
impl !RefUnwindSafe for OpenAiCompatibleBuilder
impl Send for OpenAiCompatibleBuilder
impl Sync for OpenAiCompatibleBuilder
impl Unpin for OpenAiCompatibleBuilder
impl UnsafeUnpin for OpenAiCompatibleBuilder
impl !UnwindSafe for OpenAiCompatibleBuilder
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
§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>
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