pub struct ModelConfig {
pub model: String,
pub base_url: String,
pub api_backend: ApiBackend,
pub auth: AuthScheme,
pub anthropic_version: String,
pub betas: Vec<String>,
pub extra_headers: Vec<(String, String)>,
pub max_tokens_cap: Option<u32>,
pub developer_rendering: DeveloperRendering,
pub provider_prefs: Option<Value>,
}Expand description
The per-model wire configuration record (ADR-0007 + plan §3.1/§9).
Fields§
§model: StringThe model id (native claude-…; OpenRouter anthropic/claude-…).
base_url: StringThe endpoint base URL ({base_url}/v1/messages is the request path).
api_backend: ApiBackendThe endpoint family — selects the auth header and backend quirks.
auth: AuthSchemeThe resolved credential.
anthropic_version: StringThe anthropic-version header value.
betas: Vec<String>anthropic-beta values, latched per session (plan §4.8). Defaults to
INTERLEAVED_THINKING_BETA (plan §9.3).
extra_headers: Vec<(String, String)>Extra headers appended to every request (gateway auth quirks etc.).
max_tokens_cap: Option<u32>Optional ceiling clamped onto SamplingArgs.max_tokens. None (the
default) sends the caller’s budget through untouched.
A clamp here is silent by construction — it is a min, so a caller who
deliberately asks for more gets less with no error and no way to notice.
ADR-0007 already rejects that for reasoning_effort (“never silently
clamp — that would corrupt eval comparisons”); the same reasoning
applies to the output budget, so the wire now forwards the request and
lets the API’s own error surface when a model will not accept it.
Set it to Some(n) only to pin a model whose real ceiling is lower than
DEFAULT_MAX_TOKENS — e.g. claude-3-haiku
at 4096 — where the clamp turns a 400 into a working request.
developer_rendering: DeveloperRenderingHow Developer messages are rendered.
provider_prefs: Option<Value>OpenRouter provider routing preferences. None → the default trio
(ignore: ["amazon-bedrock"], allow_fallbacks: false, require_parameters: true, matching cc-reverse-proxy) when the backend
is OpenRouter; ignored on other backends.
Vertex is deliberately not excluded — it is a production-relevant
Anthropic provider (user decision, 2026-07-18). Note from the Task-12
live smoke: Vertex honours the thinking config only when the
interleaved-thinking beta header reaches it, and cross-provider routing
between turns forfeits prompt-cache reads; pin only: ["anthropic"]
here when cache-hit determinism matters more than provider failover.
Implementations§
Source§impl ModelConfig
impl ModelConfig
Sourcepub fn new(
model: impl Into<String>,
base_url: impl Into<String>,
key: impl Into<String>,
) -> ModelConfig
pub fn new( model: impl Into<String>, base_url: impl Into<String>, key: impl Into<String>, ) -> ModelConfig
Build a config for model against base_url with key, detecting the
backend and choosing the matching auth scheme.
Sourcepub fn from_env() -> Result<ModelConfig, ProviderError>
pub fn from_env() -> Result<ModelConfig, ProviderError>
Resolve the common case from the environment: LOCODE_API_KEY (required),
LOCODE_BASE_URL (default DEFAULT_BASE_URL); the model defaults
(default DEFAULT_MODEL).
§Errors
ProviderError::Auth when LOCODE_API_KEY is unset or empty.
Sourcepub fn interleaved_thinking(&self) -> bool
pub fn interleaved_thinking(&self) -> bool
Whether the interleaved-thinking beta is active (waives the thinking budget clamp, plan §9.3).
Sourcepub fn effective_provider_prefs(&self) -> Option<Value>
pub fn effective_provider_prefs(&self) -> Option<Value>
The OpenRouter provider preferences to inject, if any (plan §9.2):
the configured value, or the default trio on the OpenRouter backend.
Trait Implementations§
Source§impl Clone for ModelConfig
impl Clone for ModelConfig
Source§fn clone(&self) -> ModelConfig
fn clone(&self) -> ModelConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more