Skip to main content

systemprompt_models/ai/
models.rs

1//! Model configuration for tool-calling and chat requests.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8
9pub use systemprompt_provider_contracts::ToolModelConfig;
10
11pub type ToolModelOverrides = HashMap<String, HashMap<String, ToolModelConfig>>;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct ModelConfig {
15    pub id: String,
16    pub max_tokens: u32,
17    pub supports_tools: bool,
18    #[serde(default)]
19    pub cost_per_1k_tokens: f32,
20}
21
22impl ModelConfig {
23    pub fn new(id: impl Into<String>, max_tokens: u32, supports_tools: bool) -> Self {
24        Self {
25            id: id.into(),
26            max_tokens,
27            supports_tools,
28            cost_per_1k_tokens: 0.0,
29        }
30    }
31
32    pub const fn with_cost(mut self, cost: f32) -> Self {
33        self.cost_per_1k_tokens = cost;
34        self
35    }
36}