Skip to main content

ProviderConfig

Struct ProviderConfig 

Source
pub struct ProviderConfig {
    pub id: String,
    pub vendor: Vendor,
    pub api: Option<String>,
    pub base_url: Option<String>,
    pub api_key_env: Option<String>,
    pub models: Vec<ModelEntry>,
    pub tiers: Tiers,
    pub quota: Quota,
    pub builtin: bool,
}
Expand description

One entry of providers.

Fields§

§id: String

Unique, of ASCII letters, digits, - and _. When the tiers define the same id twice, the first in load order (global, scene, project; each tier’s settings.local.json after its settings.json) is used and the rest ignored.

§vendor: Vendor

anthropic, openai, deepseek, qwen, vllm, sglang or generic (default). Decides how thinking is switched, whether reasoning is sent back and how effort is spelled.

§api: Option<String>

anthropic (default), openai_chat or openai_responses, or a protocol the host registered.

§base_url: Option<String>

Required for openai_chat; anthropic without one uses Anthropic’s own API, openai_responses OpenAI’s.

§api_key_env: Option<String>

The environment variable holding the key. Without one the host’s credential source is asked. No child process inherits it once a settings file names it, unless sandbox.env.allow does.

§models: Vec<ModelEntry>

The models this provider serves, each an id or an object with what the engine should know about it. Empty accepts any id. Not fetched from the provider — config.listModels does that, on request.

§tiers: Tiers

Which model serves strong, balanced and fast. strong is required; balanced defaults to strong’s, fast to balanced’s. Each must be in models when models lists any.

§quota: Quota

Token limits; past one, the provider is skipped until the period turns over.

§builtin: bool

The provider the engine supplies when the settings define none.

Implementations§

Source§

impl ProviderConfig

Source

pub const BUILTIN_ID: &'static str = "anthropic"

The id of the provider the engine supplies when the settings define none.

Source

pub fn builtin(model: &str) -> Self

The provider used when the settings define none: Anthropic’s API, keyed and addressed from the environment, every tier model.

Source

pub fn id_problem(id: &str) -> Option<String>

Why id cannot name a provider, if it cannot. The id is the name of the provider’s quota usage file as it stands, so it holds nothing a file name would have to change — and no capital, since Ab and ab are one file on a case-insensitive file system.

Source

pub fn api(&self) -> &str

api, defaulted.

Source

pub fn accepts_model(&self, model: &str) -> bool

Whether model may be sent to this provider: listed, or nothing is.

Source

pub fn lists_model(&self, model: &str) -> bool

Whether models lists model.

Source

pub fn model_ids(&self) -> Vec<&str>

Source

pub fn model_spec(&self, model: &str) -> Option<&ModelSpec>

What models says about model beyond its id, if anything.

Source

pub fn resolved_tiers(&self) -> Result<ResolvedTiers, String>

The tiers with the gaps filled, or why this entry is not usable.

Trait Implementations§

Source§

impl Clone for ProviderConfig

Source§

fn clone(&self) -> Self

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() -> Self

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 JsonSchema for ProviderConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for ProviderConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

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

impl StructuralPartialEq for ProviderConfig

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> 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> 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, !>

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