pub struct Model {Show 15 fields
pub id: String,
pub name: String,
pub api: Api,
pub provider: ProviderId,
pub base_url: String,
pub reasoning: bool,
pub thinking_level_map: Option<ThinkingLevelMap>,
pub input: Vec<InputModality>,
pub cost: ModelCost,
pub cost_configured: bool,
pub context_window: u64,
pub max_tokens: u64,
pub sampling_params: Option<Map<String, Value>>,
pub headers: Option<BTreeMap<String, String>>,
pub compat: Option<StreamingProtocolCompat>,
}Expand description
A model entry. Mirrors TS Model<TApi>; the generic is erased to a runtime
Api field so a single Model works for every provider.
Fields§
§id: String§name: String§api: Api§provider: ProviderId§base_url: String§reasoning: bool§thinking_level_map: Option<ThinkingLevelMap>§input: Vec<InputModality>§cost: ModelCost§cost_configured: boolWhether pricing was explicitly supplied, including intentionally free models.
context_window: u64§max_tokens: u64§sampling_params: Option<Map<String, Value>>§headers: Option<BTreeMap<String, String>>§compat: Option<StreamingProtocolCompat>Implementations§
Source§impl Model
impl Model
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
api: Api,
provider: impl Into<String>,
base_url: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, name: impl Into<String>, api: Api, provider: impl Into<String>, base_url: impl Into<String>, ) -> Self
Construct a minimal model with empty cost + zeroed windows.
Sourcepub fn has_pricing(&self) -> bool
pub fn has_pricing(&self) -> bool
Explicit zero rates and built-in nonzero rates both count as known pricing.
Sourcepub fn supported_thinking_levels(&self) -> Vec<ThinkingLevel>
pub fn supported_thinking_levels(&self) -> Vec<ThinkingLevel>
Returns the supported thinking levels for this model. Mirrors
getSupportedThinkingLevels: xhigh/max are only listed when their map
entry is a non-null string; other levels are supported unless mapped to null.
Sourcepub fn clamp_thinking_level(&self, requested: ThinkingLevel) -> ThinkingLevel
pub fn clamp_thinking_level(&self, requested: ThinkingLevel) -> ThinkingLevel
Clamp a requested thinking level to a supported one. Mirrors
clampThinkingLevel: walks the ordered list and accepts if supported,
otherwise falls back to the nearest lower supported level.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Model
impl<'de> Deserialize<'de> for Model
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Model
Auto Trait Implementations§
impl Freeze for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnsafeUnpin for Model
impl UnwindSafe for Model
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more