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: Stringanthropic | 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
does — GET /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
impl ProviderConfig
Sourcepub fn vision_enabled(&self) -> bool
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.
Sourcepub fn pricing(&self) -> Option<Pricing>
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.
pub fn resolve_api_key(&self) -> Option<String>
Trait Implementations§
Source§impl Clone for ProviderConfig
impl Clone for ProviderConfig
Source§fn clone(&self) -> ProviderConfig
fn clone(&self) -> ProviderConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more