artifactize_core/llm/
api.rs1use serde::{Deserialize, Serialize};
4
5use crate::config::Provider;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum Api {
10 OpenaiResponses,
11 OpenaiChat,
12 Anthropic,
13 Gemini,
14 Codex,
15 ClaudeAgent,
17}
18
19impl From<Provider> for Api {
20 fn from(provider: Provider) -> Self {
21 match provider {
22 Provider::Openai => Self::OpenaiResponses,
23 Provider::Anthropic => Self::Anthropic,
24 Provider::Gemini => Self::Gemini,
25 Provider::Codex => Self::Codex,
26 Provider::ClaudeAgent => Self::ClaudeAgent,
27 }
28 }
29}
30
31impl From<EndpointApi> for Api {
32 fn from(api: EndpointApi) -> Self {
33 match api {
34 EndpointApi::OpenaiResponses => Self::OpenaiResponses,
35 EndpointApi::OpenaiChat => Self::OpenaiChat,
36 EndpointApi::Anthropic => Self::Anthropic,
37 EndpointApi::Gemini => Self::Gemini,
38 }
39 }
40}
41
42impl Api {
43 pub fn validate_reasoning(self, reasoning: &str) -> Result<(), String> {
45 let supported = match self {
46 Self::OpenaiResponses | Self::OpenaiChat | Self::Codex => matches!(
49 reasoning,
50 "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"
51 ),
52 Self::Anthropic => matches!(reasoning, "low" | "medium" | "high" | "max"),
53 Self::ClaudeAgent => matches!(reasoning, "low" | "medium" | "high" | "xhigh" | "max"),
55 Self::Gemini => matches!(reasoning, "minimal" | "low" | "medium" | "high"),
57 };
58 if supported {
59 Ok(())
60 } else {
61 Err(format!(
62 "Unsupported reasoning {reasoning:?} for {self:?}; effort is never remapped."
63 ))
64 }
65 }
66
67 pub(crate) fn openai_schema(self) -> bool {
71 matches!(self, Self::OpenaiResponses | Self::OpenaiChat | Self::Codex)
72 }
73}
74
75#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, clap::ValueEnum)]
77#[serde(rename_all = "kebab-case")]
78pub enum EndpointApi {
79 OpenaiResponses,
81 OpenaiChat,
83 Anthropic,
85 Gemini,
87}