1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(transparent)]
5pub struct InferenceGeo(pub String);
6
7impl InferenceGeo {
8 pub fn new(value: impl Into<String>) -> Self {
9 Self(value.into())
10 }
11
12 pub fn as_str(&self) -> &str {
13 &self.0
14 }
15
16 pub fn into_inner(self) -> String {
17 self.0
18 }
19}
20
21macro_rules! extensible_string_enum {
22 ($outer:ident, $known:ident { $($variant:ident => $wire:literal),+ $(,)? }) => {
23 #[derive(Debug, Clone, PartialEq, Eq, Serialize)]
24 #[serde(untagged)]
25 #[non_exhaustive]
26 pub enum $outer {
27 Known($known),
28 Unknown(String),
29 }
30
31 impl<'de> serde::Deserialize<'de> for $outer {
35 fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
36 crate::claude::extensible::deserialize_extensible(d, Self::Known, Self::Unknown)
37 }
38 }
39
40 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
41 #[non_exhaustive]
42 pub enum $known {
43 $(
44 #[serde(rename = $wire)]
45 $variant,
46 )+
47 }
48 };
49}
50
51extensible_string_enum!(ClaudeModel, ClaudeModelKnown {
52 ClaudeSonnet5 => "claude-sonnet-5", ClaudeFable51 => "claude-fable-5-1",
53 ClaudeMythos51 => "claude-mythos-5-1", ClaudeFable5 => "claude-fable-5",
54 ClaudeMythos5 => "claude-mythos-5", ClaudeOpus5 => "claude-opus-5",
55 ClaudeOpus48 => "claude-opus-4-8", ClaudeOpus47 => "claude-opus-4-7",
56 ClaudeMythosPreview => "claude-mythos-preview", ClaudeOpus46 => "claude-opus-4-6",
57 ClaudeSonnet46 => "claude-sonnet-4-6", ClaudeHaiku45 => "claude-haiku-4-5",
58 ClaudeHaiku4520251001 => "claude-haiku-4-5-20251001", ClaudeOpus45 => "claude-opus-4-5",
59 ClaudeOpus4520251101 => "claude-opus-4-5-20251101", ClaudeSonnet45 => "claude-sonnet-4-5",
60 ClaudeSonnet4520250929 => "claude-sonnet-4-5-20250929", ClaudeOpus41 => "claude-opus-4-1",
61 ClaudeOpus4120250805 => "claude-opus-4-1-20250805", ClaudeOpus40 => "claude-opus-4-0",
62 ClaudeOpus420250514 => "claude-opus-4-20250514", ClaudeSonnet40 => "claude-sonnet-4-0",
63 ClaudeSonnet420250514 => "claude-sonnet-4-20250514", Claude3Haiku20240307 => "claude-3-haiku-20240307",
64});
65
66impl From<String> for ClaudeModel {
67 fn from(value: String) -> Self {
68 Self::Unknown(value)
69 }
70}
71
72extensible_string_enum!(AnthropicBeta, AnthropicBetaKnown {
73 MessageBatches20240924 => "message-batches-2024-09-24",
74 PromptCaching20240731 => "prompt-caching-2024-07-31",
75 ComputerUse20241022 => "computer-use-2024-10-22",
76 ComputerUse20250124 => "computer-use-2025-01-24",
77 Pdfs20240925 => "pdfs-2024-09-25",
78 TokenCounting20241101 => "token-counting-2024-11-01",
79 TokenEfficientTools20250219 => "token-efficient-tools-2025-02-19",
80 Output128k20250219 => "output-128k-2025-02-19",
81 FilesApi20250414 => "files-api-2025-04-14",
82 McpClient20250404 => "mcp-client-2025-04-04",
83 McpClient20251120 => "mcp-client-2025-11-20",
84 DevFullThinking20250514 => "dev-full-thinking-2025-05-14",
85 InterleavedThinking20250514 => "interleaved-thinking-2025-05-14",
86 CodeExecution20250522 => "code-execution-2025-05-22",
87 ExtendedCacheTtl20250411 => "extended-cache-ttl-2025-04-11",
88 Context1m20250807 => "context-1m-2025-08-07",
89 ContextManagement20250627 => "context-management-2025-06-27",
90 ModelContextWindowExceeded20250826 => "model-context-window-exceeded-2025-08-26",
91 Skills20251002 => "skills-2025-10-02",
92 FastMode20260201 => "fast-mode-2026-02-01",
93 Output300k20260324 => "output-300k-2026-03-24",
94 UserProfiles20260324 => "user-profiles-2026-03-24",
95 AdvisorTool20260301 => "advisor-tool-2026-03-01",
96 ManagedAgents20260401 => "managed-agents-2026-04-01",
97 CacheDiagnosis20260407 => "cache-diagnosis-2026-04-07",
98 ThinkingTokenCount20260513 => "thinking-token-count-2026-05-13",
99 ServerSideFallback20260601 => "server-side-fallback-2026-06-01",
100 ServerSideFallback20260701 => "server-side-fallback-2026-07-01",
101 FallbackCredit20260601 => "fallback-credit-2026-06-01",
102 FallbackCredit20260701 => "fallback-credit-2026-07-01",
103 MidConversationToolChanges20260701 => "mid-conversation-tool-changes-2026-07-01",
104 AgentMemory20260722 => "agent-memory-2026-07-22",
105 MidConversationOutputConfig20260701 => "mid-conversation-output-config-2026-07-01",
106 ThinkingBindingControls20260801 => "thinking-binding-controls-2026-08-01",
107 ThinkingDisplayUpdates20260818 => "thinking-display-updates-2026-08-18",
108 MidConversationSystemClearAt20260821 => "mid-conversation-system-clear-at-2026-08-21",
109});
110
111extensible_string_enum!(MessageRole, MessageRoleKnown { User => "user", Assistant => "assistant", System => "system" });
112extensible_string_enum!(AssistantRole, AssistantRoleKnown { Assistant => "assistant" });
113extensible_string_enum!(StopReason, StopReasonKnown {
114 EndTurn => "end_turn", MaxTokens => "max_tokens", StopSequence => "stop_sequence",
115 ToolUse => "tool_use", PauseTurn => "pause_turn", Compaction => "compaction",
116 Refusal => "refusal", ModelContextWindowExceeded => "model_context_window_exceeded",
117});
118extensible_string_enum!(RequestServiceTier, RequestServiceTierKnown { Auto => "auto", StandardOnly => "standard_only" });
119extensible_string_enum!(UsageServiceTier, UsageServiceTierKnown { Standard => "standard", Priority => "priority", Batch => "batch" });
120extensible_string_enum!(Speed, SpeedKnown { Standard => "standard", Fast => "fast" });
121extensible_string_enum!(CacheTtl, CacheTtlKnown { FiveMinutes => "5m", OneHour => "1h" });
122extensible_string_enum!(ThinkingDisplay, ThinkingDisplayKnown { Summarized => "summarized", Omitted => "omitted", Updates => "updates" });
123extensible_string_enum!(MessageClearAt, MessageClearAtKnown { NextUserMessage => "next_user_message", Never => "never" });
124extensible_string_enum!(ThinkingPrefixMismatchBehavior, ThinkingPrefixMismatchBehaviorKnown { Error => "error", DropBlock => "drop_block" });
125extensible_string_enum!(ThinkingDroppedReason, ThinkingDroppedReasonKnown {
126 ModelBindingMismatch => "model_binding_mismatch",
127 PrefixBindingMismatch => "prefix_binding_mismatch",
128 OrganizationBindingMismatch => "organization_binding_mismatch",
129 EndUserBindingMismatch => "end_user_binding_mismatch",
130});
131extensible_string_enum!(OutputEffort, OutputEffortKnown { Low => "low", Medium => "medium", High => "high", XHigh => "xhigh", Max => "max" });
132extensible_string_enum!(ServerToolUseName, ServerToolUseNameKnown {
133 Advisor => "advisor", WebSearch => "web_search", WebFetch => "web_fetch",
134 CodeExecution => "code_execution", BashCodeExecution => "bash_code_execution",
135 TextEditorCodeExecution => "text_editor_code_execution",
136 ToolSearchToolRegex => "tool_search_tool_regex", ToolSearchToolBm25 => "tool_search_tool_bm25",
137});
138extensible_string_enum!(ToolType, ToolTypeKnown {
139 Custom => "custom", Bash20241022 => "bash_20241022", Bash20250124 => "bash_20250124",
140 CodeExecution20250522 => "code_execution_20250522", CodeExecution20250825 => "code_execution_20250825",
141 CodeExecution20260120 => "code_execution_20260120", CodeExecution20260521 => "code_execution_20260521",
142 Computer20241022 => "computer_20241022",
143 Computer20250124 => "computer_20250124", Computer20251124 => "computer_20251124",
144 Memory20250818 => "memory_20250818", TextEditor20241022 => "text_editor_20241022",
145 TextEditor20250124 => "text_editor_20250124", TextEditor20250429 => "text_editor_20250429",
146 TextEditor20250728 => "text_editor_20250728", WebSearch20250305 => "web_search_20250305",
147 WebSearch20260209 => "web_search_20260209", WebSearch20260318 => "web_search_20260318",
148 WebFetch20250910 => "web_fetch_20250910",
149 WebFetch20260209 => "web_fetch_20260209", WebFetch20260309 => "web_fetch_20260309",
150 WebFetch20260318 => "web_fetch_20260318",
151 Advisor20260301 => "advisor_20260301", ToolSearchBm2520251119 => "tool_search_tool_bm25_20251119",
152 ToolSearchBm25 => "tool_search_tool_bm25", ToolSearchRegex20251119 => "tool_search_tool_regex_20251119",
153 ToolSearchRegex => "tool_search_tool_regex", McpToolset => "mcp_toolset",
154});
155extensible_string_enum!(CitationType, CitationTypeKnown {
156 CharLocation => "char_location", PageLocation => "page_location",
157 ContentBlockLocation => "content_block_location", WebSearchResultLocation => "web_search_result_location",
158 SearchResultLocation => "search_result_location",
159});
160extensible_string_enum!(MessageObjectType, MessageObjectTypeKnown { Message => "message" });
161extensible_string_enum!(ModelObjectType, ModelObjectTypeKnown { Model => "model" });
162extensible_string_enum!(FileObjectType, FileObjectTypeKnown { File => "file" });
163extensible_string_enum!(DeletedFileObjectType, DeletedFileObjectTypeKnown { FileDeleted => "file_deleted" });
164extensible_string_enum!(SkillObjectType, SkillObjectTypeKnown { Skill => "skill" });
165extensible_string_enum!(DeletedSkillObjectType, DeletedSkillObjectTypeKnown { SkillDeleted => "skill_deleted" });
166extensible_string_enum!(SkillVersionObjectType, SkillVersionObjectTypeKnown { SkillVersion => "skill_version" });
167extensible_string_enum!(DeletedSkillVersionObjectType, DeletedSkillVersionObjectTypeKnown { SkillVersionDeleted => "skill_version_deleted" });
168extensible_string_enum!(SkillSourceType, SkillSourceTypeKnown {
169 Custom => "custom", Anthropic => "anthropic", AnthropicExample => "anthropic_example",
170 Plugin => "plugin",
171});
172extensible_string_enum!(JsonSchemaObjectType, JsonSchemaObjectTypeKnown { Object => "object" });
173extensible_string_enum!(JsonSchemaFormatType, JsonSchemaFormatTypeKnown { JsonSchema => "json_schema" });
174extensible_string_enum!(McpServerType, McpServerTypeKnown { Url => "url" });
175extensible_string_enum!(TaskBudgetType, TaskBudgetTypeKnown { Tokens => "tokens" });
176extensible_string_enum!(SkillType, SkillTypeKnown { Anthropic => "anthropic", Custom => "custom" });
177extensible_string_enum!(IterationUsageType, IterationUsageTypeKnown { Message => "message", Compaction => "compaction", AdvisorMessage => "advisor_message", FallbackMessage => "fallback_message" });
178extensible_string_enum!(ContextEditType, ContextEditTypeKnown {
179 ClearToolUses20250919 => "clear_tool_uses_20250919",
180 ClearThinking20251015 => "clear_thinking_20251015",
181 Compact20260112 => "compact_20260112",
182});
183extensible_string_enum!(ResponseInclusion, ResponseInclusionKnown { Full => "full", Excluded => "excluded" });