Skip to main content

ModelConfig

Struct ModelConfig 

Source
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: String

The model id (native claude-…; OpenRouter anthropic/claude-…).

§base_url: String

The endpoint base URL ({base_url}/v1/messages is the request path).

§api_backend: ApiBackend

The endpoint family — selects the auth header and backend quirks.

§auth: AuthScheme

The resolved credential.

§anthropic_version: String

The 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: DeveloperRendering

How 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

Source

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.

Source

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.

Source

pub fn interleaved_thinking(&self) -> bool

Whether the interleaved-thinking beta is active (waives the thinking budget clamp, plan §9.3).

Source

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

Source§

fn clone(&self) -> ModelConfig

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 ModelConfig

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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