Skip to main content

ProviderConfig

Struct ProviderConfig 

Source
pub struct ProviderConfig {
Show 14 fields pub kind: String, pub model: Option<String>, pub api_key_env: Option<String>, pub api_key: Option<String>, pub base_url: Option<String>, pub input_price_per_mtok: Option<f64>, pub output_price_per_mtok: Option<f64>, pub temperature: Option<f64>, pub seed: Option<u64>, pub context_window: Option<u64>, pub vision: Option<bool>, pub max_retries: Option<u32>, pub retry_after_cap_secs: Option<u64>, pub fallbacks: Vec<String>,
}

Fields§

§kind: String

anthropic | openai | local

§model: Option<String>§api_key_env: Option<String>

Environment variable holding the key. Preferred over api_key.

§api_key: Option<String>

Inline key. Convenient, but it lands in a file on disk — prefer the env var.

§base_url: Option<String>§input_price_per_mtok: Option<f64>

Per-million-token prices, so budgets and reporting can be in dollars. Leave unset for a local model — the marginal cost really is zero.

§output_price_per_mtok: Option<f64>§temperature: Option<f64>

Sampling temperature, sent verbatim by providers that accept one. Unset means the server’s default. Do not reach for 0.0 to get repeatability: measured on qwen3.6, greedy decoding walks into verbatim repetition loops that sampling noise would have broken. Pin the server’s own default value and set seed instead — same distribution, repeatable draws. The Anthropic API rejects the parameter, so setting this on an anthropic provider is a startup error rather than a silent no-op.

§seed: Option<u64>

Sampling seed, for repeatable draws at a nonzero temperature. Only as deterministic as the backend: llama-server repeats exactly when requests run one at a time, and does not once concurrent requests share a batch. Rejected on anthropic for the same reason as temperature.

§context_window: Option<u64>

How many tokens this model’s context holds — for a local server, the -c it was started with.

Nothing here can discover this: a provider reports how many tokens a prompt used, never how many are left. Without it the compaction threshold has to be an absolute number somebody remembers to set, and when nobody does, a long session dies on a raw exceed_context_size_error from the server with the whole run lost. With it, AgentConfig::compact_at derives a threshold and the CLI can show how much room is left.

§vision: Option<bool>

Whether the model on the other end can see an image.

Declared rather than discovered, for the same reason context_window is: the Anthropic API has no endpoint that answers it. llama-server doesGET /props reports modalities.vision — so preflight checks the two against each other and warns on a disagreement in either direction. Both directions matter and for different reasons: declared-but-not-served means every image silently degrades to a line of text, and served-but-not-declared means a projector is loaded, paid for in memory, and never used.

Unset defaults to true for kind = "anthropic" (every Claude model in the family sees) and false everywhere else. False is the safe default for a local server because the failure it prevents is the expensive one: an image_url part sent to a text-only llama-server is a failed request, where an image rendered as text is merely a model that cannot see — which is what it was before.

A vision model is two files. The weights carry the language model; the vision tower ships beside them as a separate mmproj-*.gguf that --mmproj must name. --mmproj-auto is on by default and only fires for -hf downloads, so every start script here using -m <path> gets nothing from it. See docs/LLAMA-SERVER.md.

§max_retries: Option<u32>

Retries per request on transient failures — 429, 5xx, transport. 0 disables. Unset means 3. Auth, billing, invalid-request and context-overflow errors are never retried: the same payload fails the same way, and overflow belongs to the compaction path.

§retry_after_cap_secs: Option<u64>

A Retry-After above this many seconds is surfaced as a failure instead of slept through (default 60) — a provider can name a wait long enough that the process is simply asleep, and control never returns to a layer that could fall back instead.

§fallbacks: Vec<String>

Provider entries to try, in order, when this one exhausts its retries on a transient failure. Turn-local: the next turn starts from this provider again. Each fallback answers with its own model. Empty — the default — means strict: fail rather than silently answer with a different model. mecha eval never falls back regardless: a scorecard grades the model it names.

Implementations§

Source§

impl ProviderConfig

Source

pub fn vision_enabled(&self) -> bool

Whether to render images onto this provider’s wire.

The default is per-kind rather than a flat false because the two kinds know different amounts: every model in the Anthropic family this harness speaks to has vision, and nothing about a local server is knowable from config alone.

Source

pub fn pricing(&self) -> Option<Pricing>

Prices, if configured. Both halves are required: knowing one is worse than knowing neither, because it silently under-reports.

Source

pub fn resolve_api_key(&self) -> Option<String>

Trait Implementations§

Source§

impl Clone for ProviderConfig

Source§

fn clone(&self) -> ProviderConfig

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ProviderConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProviderConfig

Source§

fn default() -> ProviderConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ProviderConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ProviderConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

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

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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> 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 = !

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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