| name | Model Routing |
| description | This skill should be used when implementing LLM model routing for cost optimization - Cratos key differentiator. |
| version | 1.0.0 |
Model Routing
Cratos ์ฐจ๋ณํ ๊ธฐ๋ฅ - ์์
๋ณ ๋ชจ๋ธ ์๋ ์ ํ์ผ๋ก ๋น์ฉ 70% ์ ๊ฐ.
์์
์ ํ
pub enum TaskType {
Classification,
Summarization,
Planning,
CodeGeneration,
ToolCalling,
Polishing,
}
๋ผ์ฐํ
ํ
์ด๋ธ
| TaskType | Anthropic | OpenAI | ๋น์ฉ/1M |
|---|
| Classification | claude-3-haiku | gpt-4o-mini | $0.25 |
| Summarization | claude-3-haiku | gpt-4o-mini | $0.25 |
| Planning | claude-sonnet-4 | gpt-4o | $3.00 |
| CodeGeneration | claude-sonnet-4 | gpt-4o | $3.00 |
| Polishing | claude-3-haiku | gpt-4o-mini | $0.25 |
๋ผ์ฐํฐ ๊ตฌํ
pub struct ModelRouter {
config: RouterConfig,
}
impl ModelRouter {
pub fn select_model(&self, task: TaskType, context: &Context) -> ModelConfig {
if let Some(m) = context.user_model_override {
return m;
}
match task {
TaskType::Classification |
TaskType::Summarization |
TaskType::Polishing => self.config.fast_model.clone(),
TaskType::Planning |
TaskType::CodeGeneration |
TaskType::ToolCalling => self.config.smart_model.clone(),
}
}
}
๋น์ฉ ์ถ์
pub fn estimate_cost(model: &str, input: u32, output: u32) -> f64 {
let (in_rate, out_rate) = match model {
"claude-3-haiku" | "gpt-4o-mini" => (0.00025, 0.00125),
"claude-sonnet-4" | "gpt-4o" => (0.003, 0.015),
_ => (0.003, 0.015),
};
(input as f64 / 1000.0) * in_rate + (output as f64 / 1000.0) * out_rate
}
์ฐธ์กฐ
.cratos/skills/llm-agent/resources/routing-strategy.md