1use crate::Platform;
14use serde::{Deserialize, Serialize};
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
18#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
19#[serde(rename_all = "kebab-case")]
20pub enum ClientApi {
21 OpenAiChatCompletions,
22 OpenAiResponses,
23 AnthropicMessages,
24}
25
26impl ClientApi {
27 pub const ALL: [Self; 3] = [
30 Self::OpenAiChatCompletions,
31 Self::OpenAiResponses,
32 Self::AnthropicMessages,
33 ];
34}
35
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
40#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
41#[serde(rename_all = "lowercase")]
42pub enum ProviderApi {
43 OpenAi,
45 Anthropic,
47 OpenAiResponses,
50}
51
52#[derive(Debug, Clone, Copy, PartialEq, Eq)]
57pub enum Activation {
58 OutOfBox,
60 RequiresOneTimeStep(&'static str),
62}
63
64#[derive(Debug, Clone)]
68pub struct CatalogModel {
69 pub public_id: &'static str,
70 pub cloud: Platform,
71 pub upstream_id: &'static str,
72 pub client_apis: &'static [ClientApi],
75 pub provider_api: ProviderApi,
76}
77
78#[derive(Debug, Clone, Copy)]
81pub struct DirectAnthropicModel {
82 pub public_id: &'static str,
83 pub upstream_id: &'static str,
84}
85
86#[derive(Debug, Clone, Copy)]
93pub struct DirectOpenAiModel {
94 pub public_id: &'static str,
95 pub client_apis: &'static [ClientApi],
96}
97
98#[derive(Debug, Clone, Copy, PartialEq, Eq)]
104pub enum DirectDatabricksUpstream {
105 ServingEndpointChat { endpoint: &'static str },
106 ModelServiceChat { service: &'static str },
107 ModelServiceMessages { service: &'static str },
108}
109
110impl DirectDatabricksUpstream {
111 pub const fn model_id(self) -> &'static str {
112 match self {
113 Self::ServingEndpointChat { endpoint } => endpoint,
114 Self::ModelServiceChat { service } | Self::ModelServiceMessages { service } => service,
115 }
116 }
117
118 pub const fn client_api(self) -> ClientApi {
119 match self {
120 Self::ServingEndpointChat { .. } | Self::ModelServiceChat { .. } => {
121 ClientApi::OpenAiChatCompletions
122 }
123 Self::ModelServiceMessages { .. } => ClientApi::AnthropicMessages,
124 }
125 }
126}
127
128#[derive(Debug, Clone, Copy)]
130pub struct DirectDatabricksModel {
131 pub public_id: &'static str,
132 pub upstream: DirectDatabricksUpstream,
133}
134
135impl DirectAnthropicModel {
136 pub fn display_name(&self) -> &'static str {
137 resolve(self.public_id)
138 .map(CatalogModel::display_name)
139 .unwrap_or(self.public_id)
140 }
141}
142
143impl CatalogModel {
144 pub fn provider(&self) -> &'static str {
147 let id = self.public_id;
148 if id.starts_with("claude") {
149 "anthropic"
150 } else if id.starts_with("gpt") || id == "model-router" {
151 "openai"
152 } else if id.starts_with("gemini") || id.starts_with("gemma") {
153 "google"
154 } else if id.starts_with("qwen") {
155 "qwen"
156 } else if id.starts_with("deepseek") {
157 "deepseek"
158 } else if id.starts_with("mistral")
159 || id.starts_with("devstral")
160 || id.starts_with("magistral")
161 || id.starts_with("ministral")
162 {
163 "mistral"
164 } else if id.starts_with("minimax") {
165 "minimax"
166 } else if id.starts_with("kimi") {
167 "moonshotai"
168 } else if id.starts_with("nemotron") {
169 "nvidia"
170 } else if id.starts_with("glm") {
171 "zai"
172 } else if id.starts_with("palmyra") {
173 "writer"
174 } else {
175 "unknown"
176 }
177 }
178
179 pub fn display_name(&self) -> &'static str {
182 match self.public_id {
183 "gpt-5.6-sol" => "GPT-5.6 Sol",
184 "gpt-5.6-terra" => "GPT-5.6 Terra",
185 "gpt-5.6-luna" => "GPT-5.6 Luna",
186 "gpt-5.5" => "GPT-5.5",
187 "gpt-5.4" => "GPT-5.4",
188 "gpt-oss-20b" => "GPT-OSS 20B",
189 "gpt-oss-120b" => "GPT-OSS 120B",
190 "gpt-oss-safeguard-20b" => "GPT-OSS Safeguard 20B",
191 "gpt-oss-safeguard-120b" => "GPT-OSS Safeguard 120B",
192 "deepseek-v3.2" => "DeepSeek V3.2",
193 "qwen3-32b" => "Qwen3 32B",
194 "qwen3-coder-30b" => "Qwen3 Coder 30B",
195 "qwen3-next-80b" => "Qwen3 Next 80B",
196 "qwen3-vl-235b" => "Qwen3 VL 235B",
197 "mistral-large-3" => "Mistral Large 3",
198 "devstral-2" => "Devstral 2",
199 "magistral-small" => "Magistral Small",
200 "ministral-3-14b" => "Ministral 3 14B",
201 "ministral-3-8b" => "Ministral 3 8B",
202 "ministral-3-3b" => "Ministral 3 3B",
203 "minimax-m2" => "MiniMax M2",
204 "minimax-m2.1" => "MiniMax M2.1",
205 "minimax-m2.5" => "MiniMax M2.5",
206 "kimi-k2.5" => "Kimi K2.5",
207 "nemotron-nano-9b" => "Nemotron Nano 9B",
208 "nemotron-nano-12b" => "Nemotron Nano 12B",
209 "nemotron-nano-3-30b" => "Nemotron Nano 3 30B",
210 "nemotron-super-3-120b" => "Nemotron Super 3 120B",
211 "gemma-3-4b" => "Gemma 3 4B",
212 "gemma-3-12b" => "Gemma 3 12B",
213 "gemma-3-27b" => "Gemma 3 27B",
214 "glm-4.7" => "GLM 4.7",
215 "glm-4.7-flash" => "GLM 4.7 Flash",
216 "glm-5" => "GLM 5",
217 "palmyra-vision-7b" => "Palmyra Vision 7B",
218 "claude-opus-5" => "Claude Opus 5",
219 "claude-sonnet-5" => "Claude Sonnet 5",
220 "claude-opus-4.8" => "Claude Opus 4.8",
221 "claude-opus-4.7" => "Claude Opus 4.7",
222 "claude-opus-4.6" => "Claude Opus 4.6",
223 "claude-opus-4.5" => "Claude Opus 4.5",
224 "claude-sonnet-4.6" => "Claude Sonnet 4.6",
225 "claude-sonnet-4.5" => "Claude Sonnet 4.5",
226 "claude-haiku-4.5" => "Claude Haiku 4.5",
227 "claude-fable-5" => "Claude Fable 5",
228 "gemini-2.5-pro" => "Gemini 2.5 Pro",
229 "gemini-2.5-flash" => "Gemini 2.5 Flash",
230 "gemini-2.5-flash-lite" => "Gemini 2.5 Flash Lite",
231 "gemini-3.5-flash" => "Gemini 3.5 Flash",
232 "gemini-3.1-flash-lite" => "Gemini 3.1 Flash Lite",
233 "gpt-4.1" => "GPT-4.1",
234 "gpt-4o-mini" => "GPT-4o mini",
235 "model-router" => "Model Router",
236 other => other,
237 }
238 }
239
240 pub fn activation(&self) -> Activation {
243 if !self.public_id.starts_with("claude") {
244 return Activation::OutOfBox;
245 }
246 match self.cloud {
247 Platform::Aws => Activation::RequiresOneTimeStep(
248 "Submit the one-time Anthropic use-case form in the Bedrock console.",
249 ),
250 Platform::Gcp => Activation::RequiresOneTimeStep(
251 "Enable Claude in Vertex AI Model Garden and accept Anthropic's terms of service, one-time, in the Google Cloud console.",
252 ),
253 Platform::Azure => Activation::RequiresOneTimeStep(
254 "Accept the Marketplace terms and create the Claude deployment in the Microsoft Foundry portal (one-time).",
255 ),
256 _ => Activation::OutOfBox,
257 }
258 }
259}
260
261pub fn bedrock_geo(region: &str) -> &'static str {
271 if region.starts_with("us-gov-") {
272 "us-gov"
273 } else if region.starts_with("us-") {
274 "us"
275 } else {
276 "global"
277 }
278}
279
280pub fn bedrock_inference_profile_id(region: &str, upstream_id: &str) -> String {
284 format!("{}.{}", bedrock_geo(region), upstream_id)
285}
286
287static CATALOG: &[CatalogModel] = &[
288 CatalogModel {
294 public_id: "gpt-5.6-sol",
295 cloud: Platform::Aws,
296 upstream_id: "openai.gpt-5.6-sol",
297 client_apis: &[ClientApi::OpenAiResponses],
298 provider_api: ProviderApi::OpenAiResponses,
299 },
300 CatalogModel {
301 public_id: "gpt-5.6-terra",
302 cloud: Platform::Aws,
303 upstream_id: "openai.gpt-5.6-terra",
304 client_apis: &[ClientApi::OpenAiResponses],
305 provider_api: ProviderApi::OpenAiResponses,
306 },
307 CatalogModel {
308 public_id: "gpt-5.6-luna",
309 cloud: Platform::Aws,
310 upstream_id: "openai.gpt-5.6-luna",
311 client_apis: &[ClientApi::OpenAiResponses],
312 provider_api: ProviderApi::OpenAiResponses,
313 },
314 CatalogModel {
315 public_id: "gpt-5.5",
316 cloud: Platform::Aws,
317 upstream_id: "openai.gpt-5.5",
318 client_apis: &[ClientApi::OpenAiResponses],
319 provider_api: ProviderApi::OpenAiResponses,
320 },
321 CatalogModel {
322 public_id: "gpt-5.4",
323 cloud: Platform::Aws,
324 upstream_id: "openai.gpt-5.4",
325 client_apis: &[ClientApi::OpenAiResponses],
326 provider_api: ProviderApi::OpenAiResponses,
327 },
328 CatalogModel {
329 public_id: "gpt-oss-20b",
330 cloud: Platform::Aws,
331 upstream_id: "openai.gpt-oss-20b-1:0",
332 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
333 provider_api: ProviderApi::OpenAi,
334 },
335 CatalogModel {
336 public_id: "gpt-oss-120b",
337 cloud: Platform::Aws,
338 upstream_id: "openai.gpt-oss-120b-1:0",
339 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
340 provider_api: ProviderApi::OpenAi,
341 },
342 CatalogModel {
343 public_id: "gpt-oss-safeguard-20b",
344 cloud: Platform::Aws,
345 upstream_id: "openai.gpt-oss-safeguard-20b",
346 client_apis: &[ClientApi::OpenAiChatCompletions],
347 provider_api: ProviderApi::OpenAi,
348 },
349 CatalogModel {
350 public_id: "gpt-oss-safeguard-120b",
351 cloud: Platform::Aws,
352 upstream_id: "openai.gpt-oss-safeguard-120b",
353 client_apis: &[ClientApi::OpenAiChatCompletions],
354 provider_api: ProviderApi::OpenAi,
355 },
356 CatalogModel {
357 public_id: "deepseek-v3.2",
358 cloud: Platform::Aws,
359 upstream_id: "deepseek.v3.2",
360 client_apis: &[ClientApi::OpenAiChatCompletions],
361 provider_api: ProviderApi::OpenAi,
362 },
363 CatalogModel {
364 public_id: "qwen3-32b",
365 cloud: Platform::Aws,
366 upstream_id: "qwen.qwen3-32b-v1:0",
367 client_apis: &[ClientApi::OpenAiChatCompletions],
368 provider_api: ProviderApi::OpenAi,
369 },
370 CatalogModel {
371 public_id: "qwen3-coder-30b",
372 cloud: Platform::Aws,
373 upstream_id: "qwen.qwen3-coder-30b-a3b-v1:0",
374 client_apis: &[ClientApi::OpenAiChatCompletions],
375 provider_api: ProviderApi::OpenAi,
376 },
377 CatalogModel {
378 public_id: "qwen3-next-80b",
379 cloud: Platform::Aws,
380 upstream_id: "qwen.qwen3-next-80b-a3b",
381 client_apis: &[ClientApi::OpenAiChatCompletions],
382 provider_api: ProviderApi::OpenAi,
383 },
384 CatalogModel {
385 public_id: "qwen3-vl-235b",
386 cloud: Platform::Aws,
387 upstream_id: "qwen.qwen3-vl-235b-a22b",
388 client_apis: &[ClientApi::OpenAiChatCompletions],
389 provider_api: ProviderApi::OpenAi,
390 },
391 CatalogModel {
392 public_id: "mistral-large-3",
393 cloud: Platform::Aws,
394 upstream_id: "mistral.mistral-large-3-675b-instruct",
395 client_apis: &[ClientApi::OpenAiChatCompletions],
396 provider_api: ProviderApi::OpenAi,
397 },
398 CatalogModel {
399 public_id: "devstral-2",
400 cloud: Platform::Aws,
401 upstream_id: "mistral.devstral-2-123b",
402 client_apis: &[ClientApi::OpenAiChatCompletions],
403 provider_api: ProviderApi::OpenAi,
404 },
405 CatalogModel {
406 public_id: "magistral-small",
407 cloud: Platform::Aws,
408 upstream_id: "mistral.magistral-small-2509",
409 client_apis: &[ClientApi::OpenAiChatCompletions],
410 provider_api: ProviderApi::OpenAi,
411 },
412 CatalogModel {
413 public_id: "ministral-3-14b",
414 cloud: Platform::Aws,
415 upstream_id: "mistral.ministral-3-14b-instruct",
416 client_apis: &[ClientApi::OpenAiChatCompletions],
417 provider_api: ProviderApi::OpenAi,
418 },
419 CatalogModel {
420 public_id: "ministral-3-8b",
421 cloud: Platform::Aws,
422 upstream_id: "mistral.ministral-3-8b-instruct",
423 client_apis: &[ClientApi::OpenAiChatCompletions],
424 provider_api: ProviderApi::OpenAi,
425 },
426 CatalogModel {
427 public_id: "ministral-3-3b",
428 cloud: Platform::Aws,
429 upstream_id: "mistral.ministral-3-3b-instruct",
430 client_apis: &[ClientApi::OpenAiChatCompletions],
431 provider_api: ProviderApi::OpenAi,
432 },
433 CatalogModel {
434 public_id: "minimax-m2",
435 cloud: Platform::Aws,
436 upstream_id: "minimax.minimax-m2",
437 client_apis: &[ClientApi::OpenAiChatCompletions],
438 provider_api: ProviderApi::OpenAi,
439 },
440 CatalogModel {
441 public_id: "minimax-m2.1",
442 cloud: Platform::Aws,
443 upstream_id: "minimax.minimax-m2.1",
444 client_apis: &[ClientApi::OpenAiChatCompletions],
445 provider_api: ProviderApi::OpenAi,
446 },
447 CatalogModel {
448 public_id: "minimax-m2.5",
449 cloud: Platform::Aws,
450 upstream_id: "minimax.minimax-m2.5",
451 client_apis: &[ClientApi::OpenAiChatCompletions],
452 provider_api: ProviderApi::OpenAi,
453 },
454 CatalogModel {
455 public_id: "kimi-k2.5",
456 cloud: Platform::Aws,
457 upstream_id: "moonshotai.kimi-k2.5",
458 client_apis: &[ClientApi::OpenAiChatCompletions],
459 provider_api: ProviderApi::OpenAi,
460 },
461 CatalogModel {
462 public_id: "nemotron-nano-9b",
463 cloud: Platform::Aws,
464 upstream_id: "nvidia.nemotron-nano-9b-v2",
465 client_apis: &[ClientApi::OpenAiChatCompletions],
466 provider_api: ProviderApi::OpenAi,
467 },
468 CatalogModel {
469 public_id: "nemotron-nano-12b",
470 cloud: Platform::Aws,
471 upstream_id: "nvidia.nemotron-nano-12b-v2",
472 client_apis: &[ClientApi::OpenAiChatCompletions],
473 provider_api: ProviderApi::OpenAi,
474 },
475 CatalogModel {
476 public_id: "nemotron-nano-3-30b",
477 cloud: Platform::Aws,
478 upstream_id: "nvidia.nemotron-nano-3-30b",
479 client_apis: &[ClientApi::OpenAiChatCompletions],
480 provider_api: ProviderApi::OpenAi,
481 },
482 CatalogModel {
483 public_id: "nemotron-super-3-120b",
484 cloud: Platform::Aws,
485 upstream_id: "nvidia.nemotron-super-3-120b",
486 client_apis: &[ClientApi::OpenAiChatCompletions],
487 provider_api: ProviderApi::OpenAi,
488 },
489 CatalogModel {
490 public_id: "gemma-3-4b",
491 cloud: Platform::Aws,
492 upstream_id: "google.gemma-3-4b-it",
493 client_apis: &[ClientApi::OpenAiChatCompletions],
494 provider_api: ProviderApi::OpenAi,
495 },
496 CatalogModel {
497 public_id: "gemma-3-12b",
498 cloud: Platform::Aws,
499 upstream_id: "google.gemma-3-12b-it",
500 client_apis: &[ClientApi::OpenAiChatCompletions],
501 provider_api: ProviderApi::OpenAi,
502 },
503 CatalogModel {
504 public_id: "gemma-3-27b",
505 cloud: Platform::Aws,
506 upstream_id: "google.gemma-3-27b-it",
507 client_apis: &[ClientApi::OpenAiChatCompletions],
508 provider_api: ProviderApi::OpenAi,
509 },
510 CatalogModel {
511 public_id: "glm-4.7",
512 cloud: Platform::Aws,
513 upstream_id: "zai.glm-4.7",
514 client_apis: &[ClientApi::OpenAiChatCompletions],
515 provider_api: ProviderApi::OpenAi,
516 },
517 CatalogModel {
518 public_id: "glm-4.7-flash",
519 cloud: Platform::Aws,
520 upstream_id: "zai.glm-4.7-flash",
521 client_apis: &[ClientApi::OpenAiChatCompletions],
522 provider_api: ProviderApi::OpenAi,
523 },
524 CatalogModel {
525 public_id: "glm-5",
526 cloud: Platform::Aws,
527 upstream_id: "zai.glm-5",
528 client_apis: &[ClientApi::OpenAiChatCompletions],
529 provider_api: ProviderApi::OpenAi,
530 },
531 CatalogModel {
532 public_id: "palmyra-vision-7b",
533 cloud: Platform::Aws,
534 upstream_id: "writer.palmyra-vision-7b",
535 client_apis: &[ClientApi::OpenAiChatCompletions],
536 provider_api: ProviderApi::OpenAi,
537 },
538 CatalogModel {
545 public_id: "claude-opus-5",
546 cloud: Platform::Aws,
547 upstream_id: "anthropic.claude-opus-5",
548 client_apis: &[ClientApi::AnthropicMessages],
549 provider_api: ProviderApi::Anthropic,
550 },
551 CatalogModel {
552 public_id: "claude-sonnet-5",
553 cloud: Platform::Aws,
554 upstream_id: "anthropic.claude-sonnet-5",
555 client_apis: &[ClientApi::AnthropicMessages],
556 provider_api: ProviderApi::Anthropic,
557 },
558 CatalogModel {
559 public_id: "claude-opus-4.8",
560 cloud: Platform::Aws,
561 upstream_id: "anthropic.claude-opus-4-8",
562 client_apis: &[ClientApi::AnthropicMessages],
563 provider_api: ProviderApi::Anthropic,
564 },
565 CatalogModel {
566 public_id: "claude-opus-4.7",
567 cloud: Platform::Aws,
568 upstream_id: "anthropic.claude-opus-4-7",
569 client_apis: &[ClientApi::AnthropicMessages],
570 provider_api: ProviderApi::Anthropic,
571 },
572 CatalogModel {
573 public_id: "claude-opus-4.6",
574 cloud: Platform::Aws,
575 upstream_id: "anthropic.claude-opus-4-6-v1",
576 client_apis: &[ClientApi::AnthropicMessages],
577 provider_api: ProviderApi::Anthropic,
578 },
579 CatalogModel {
580 public_id: "claude-opus-4.5",
581 cloud: Platform::Aws,
582 upstream_id: "anthropic.claude-opus-4-5-20251101-v1:0",
583 client_apis: &[ClientApi::AnthropicMessages],
584 provider_api: ProviderApi::Anthropic,
585 },
586 CatalogModel {
587 public_id: "claude-sonnet-4.6",
588 cloud: Platform::Aws,
589 upstream_id: "anthropic.claude-sonnet-4-6",
590 client_apis: &[ClientApi::AnthropicMessages],
591 provider_api: ProviderApi::Anthropic,
592 },
593 CatalogModel {
594 public_id: "claude-sonnet-4.5",
595 cloud: Platform::Aws,
596 upstream_id: "anthropic.claude-sonnet-4-5-20250929-v1:0",
597 client_apis: &[ClientApi::AnthropicMessages],
598 provider_api: ProviderApi::Anthropic,
599 },
600 CatalogModel {
601 public_id: "claude-haiku-4.5",
602 cloud: Platform::Aws,
603 upstream_id: "anthropic.claude-haiku-4-5-20251001-v1:0",
604 client_apis: &[ClientApi::AnthropicMessages],
605 provider_api: ProviderApi::Anthropic,
606 },
607 CatalogModel {
608 public_id: "claude-fable-5",
609 cloud: Platform::Aws,
610 upstream_id: "anthropic.claude-fable-5",
611 client_apis: &[ClientApi::AnthropicMessages],
612 provider_api: ProviderApi::Anthropic,
613 },
614 CatalogModel {
617 public_id: "gemini-2.5-pro",
618 cloud: Platform::Gcp,
619 upstream_id: "google/gemini-2.5-pro",
620 client_apis: &[ClientApi::OpenAiChatCompletions],
621 provider_api: ProviderApi::OpenAi,
622 },
623 CatalogModel {
624 public_id: "gemini-2.5-flash",
625 cloud: Platform::Gcp,
626 upstream_id: "google/gemini-2.5-flash",
627 client_apis: &[ClientApi::OpenAiChatCompletions],
628 provider_api: ProviderApi::OpenAi,
629 },
630 CatalogModel {
631 public_id: "gemini-2.5-flash-lite",
632 cloud: Platform::Gcp,
633 upstream_id: "google/gemini-2.5-flash-lite",
634 client_apis: &[ClientApi::OpenAiChatCompletions],
635 provider_api: ProviderApi::OpenAi,
636 },
637 CatalogModel {
638 public_id: "gemini-3.5-flash",
639 cloud: Platform::Gcp,
640 upstream_id: "google/gemini-3.5-flash",
641 client_apis: &[ClientApi::OpenAiChatCompletions],
642 provider_api: ProviderApi::OpenAi,
643 },
644 CatalogModel {
645 public_id: "gemini-3.1-flash-lite",
646 cloud: Platform::Gcp,
647 upstream_id: "google/gemini-3.1-flash-lite",
648 client_apis: &[ClientApi::OpenAiChatCompletions],
649 provider_api: ProviderApi::OpenAi,
650 },
651 CatalogModel {
656 public_id: "claude-opus-5",
657 cloud: Platform::Gcp,
658 upstream_id: "claude-opus-5",
659 client_apis: &[ClientApi::AnthropicMessages],
660 provider_api: ProviderApi::Anthropic,
661 },
662 CatalogModel {
663 public_id: "claude-sonnet-5",
664 cloud: Platform::Gcp,
665 upstream_id: "claude-sonnet-5",
666 client_apis: &[ClientApi::AnthropicMessages],
667 provider_api: ProviderApi::Anthropic,
668 },
669 CatalogModel {
670 public_id: "claude-opus-4.8",
671 cloud: Platform::Gcp,
672 upstream_id: "claude-opus-4-8",
673 client_apis: &[ClientApi::AnthropicMessages],
674 provider_api: ProviderApi::Anthropic,
675 },
676 CatalogModel {
677 public_id: "claude-opus-4.7",
678 cloud: Platform::Gcp,
679 upstream_id: "claude-opus-4-7",
680 client_apis: &[ClientApi::AnthropicMessages],
681 provider_api: ProviderApi::Anthropic,
682 },
683 CatalogModel {
684 public_id: "claude-opus-4.6",
685 cloud: Platform::Gcp,
686 upstream_id: "claude-opus-4-6",
687 client_apis: &[ClientApi::AnthropicMessages],
688 provider_api: ProviderApi::Anthropic,
689 },
690 CatalogModel {
691 public_id: "claude-opus-4.5",
692 cloud: Platform::Gcp,
693 upstream_id: "claude-opus-4-5@20251101",
694 client_apis: &[ClientApi::AnthropicMessages],
695 provider_api: ProviderApi::Anthropic,
696 },
697 CatalogModel {
698 public_id: "claude-sonnet-4.6",
699 cloud: Platform::Gcp,
700 upstream_id: "claude-sonnet-4-6",
701 client_apis: &[ClientApi::AnthropicMessages],
702 provider_api: ProviderApi::Anthropic,
703 },
704 CatalogModel {
705 public_id: "claude-sonnet-4.5",
706 cloud: Platform::Gcp,
707 upstream_id: "claude-sonnet-4-5@20250929",
708 client_apis: &[ClientApi::AnthropicMessages],
709 provider_api: ProviderApi::Anthropic,
710 },
711 CatalogModel {
712 public_id: "claude-haiku-4.5",
713 cloud: Platform::Gcp,
714 upstream_id: "claude-haiku-4-5@20251001",
715 client_apis: &[ClientApi::AnthropicMessages],
716 provider_api: ProviderApi::Anthropic,
717 },
718 CatalogModel {
719 public_id: "claude-fable-5",
720 cloud: Platform::Gcp,
721 upstream_id: "claude-fable-5",
722 client_apis: &[ClientApi::AnthropicMessages],
723 provider_api: ProviderApi::Anthropic,
724 },
725 CatalogModel {
729 public_id: "gpt-4.1",
730 cloud: Platform::Azure,
731 upstream_id: "gpt-4.1",
732 client_apis: &[ClientApi::OpenAiChatCompletions],
733 provider_api: ProviderApi::OpenAi,
734 },
735 CatalogModel {
736 public_id: "gpt-4o-mini",
737 cloud: Platform::Azure,
738 upstream_id: "gpt-4o-mini",
739 client_apis: &[ClientApi::OpenAiChatCompletions],
740 provider_api: ProviderApi::OpenAi,
741 },
742 CatalogModel {
743 public_id: "model-router",
744 cloud: Platform::Azure,
745 upstream_id: "model-router",
746 client_apis: &[ClientApi::OpenAiChatCompletions],
747 provider_api: ProviderApi::OpenAi,
748 },
749 CatalogModel {
752 public_id: "gpt-5.5",
753 cloud: Platform::Azure,
754 upstream_id: "gpt-5.5",
755 client_apis: &[ClientApi::OpenAiResponses],
756 provider_api: ProviderApi::OpenAiResponses,
757 },
758 CatalogModel {
759 public_id: "gpt-5.6-sol",
760 cloud: Platform::Azure,
761 upstream_id: "gpt-5.6-sol",
762 client_apis: &[ClientApi::OpenAiResponses],
763 provider_api: ProviderApi::OpenAiResponses,
764 },
765 CatalogModel {
773 public_id: "claude-opus-5",
774 cloud: Platform::Azure,
775 upstream_id: "claude-opus-5",
776 client_apis: &[ClientApi::AnthropicMessages],
777 provider_api: ProviderApi::Anthropic,
778 },
779 CatalogModel {
780 public_id: "claude-sonnet-5",
781 cloud: Platform::Azure,
782 upstream_id: "claude-sonnet-5",
783 client_apis: &[ClientApi::AnthropicMessages],
784 provider_api: ProviderApi::Anthropic,
785 },
786 CatalogModel {
787 public_id: "claude-opus-4.8",
788 cloud: Platform::Azure,
789 upstream_id: "claude-opus-4-8",
790 client_apis: &[ClientApi::AnthropicMessages],
791 provider_api: ProviderApi::Anthropic,
792 },
793 CatalogModel {
794 public_id: "claude-opus-4.7",
795 cloud: Platform::Azure,
796 upstream_id: "claude-opus-4-7",
797 client_apis: &[ClientApi::AnthropicMessages],
798 provider_api: ProviderApi::Anthropic,
799 },
800 CatalogModel {
801 public_id: "claude-opus-4.6",
802 cloud: Platform::Azure,
803 upstream_id: "claude-opus-4-6",
804 client_apis: &[ClientApi::AnthropicMessages],
805 provider_api: ProviderApi::Anthropic,
806 },
807 CatalogModel {
808 public_id: "claude-opus-4.5",
809 cloud: Platform::Azure,
810 upstream_id: "claude-opus-4-5",
811 client_apis: &[ClientApi::AnthropicMessages],
812 provider_api: ProviderApi::Anthropic,
813 },
814 CatalogModel {
815 public_id: "claude-sonnet-4.6",
816 cloud: Platform::Azure,
817 upstream_id: "claude-sonnet-4-6",
818 client_apis: &[ClientApi::AnthropicMessages],
819 provider_api: ProviderApi::Anthropic,
820 },
821 CatalogModel {
822 public_id: "claude-sonnet-4.5",
823 cloud: Platform::Azure,
824 upstream_id: "claude-sonnet-4-5",
825 client_apis: &[ClientApi::AnthropicMessages],
826 provider_api: ProviderApi::Anthropic,
827 },
828 CatalogModel {
829 public_id: "claude-haiku-4.5",
830 cloud: Platform::Azure,
831 upstream_id: "claude-haiku-4-5",
832 client_apis: &[ClientApi::AnthropicMessages],
833 provider_api: ProviderApi::Anthropic,
834 },
835 CatalogModel {
836 public_id: "claude-fable-5",
837 cloud: Platform::Azure,
838 upstream_id: "claude-fable-5",
839 client_apis: &[ClientApi::AnthropicMessages],
840 provider_api: ProviderApi::Anthropic,
841 },
842];
843
844pub const AI_CATALOG_REVISION: &str = "2026-08-20.1";
848
849static AZURE_DEPLOYMENTS: &[(&str, &str, &str, i32)] = &[
858 ("gpt-4.1", "gpt-4.1", "2025-04-14", 50),
859 ("model-router", "model-router", "2025-11-18", 50),
860 ("gpt-5.5", "gpt-5.5", "2026-04-24", 50),
861 ("gpt-5.6-sol", "gpt-5.6-sol", "2026-07-09", 50),
862 ("text-embedding-3-large", "text-embedding-3-large", "1", 50),
863];
864
865#[derive(Debug, Clone, Copy)]
869pub struct EmbeddingModel {
870 pub public_id: &'static str,
871 pub cloud: Platform,
872 pub upstream_id: &'static str,
874}
875
876static EMBEDDING_MODELS: &[EmbeddingModel] = &[EmbeddingModel {
877 public_id: "text-embedding-3-large",
878 cloud: Platform::Azure,
879 upstream_id: "text-embedding-3-large",
880}];
881
882pub fn resolve_embedding_for(model_id: &str, cloud: Platform) -> Option<&'static EmbeddingModel> {
884 EMBEDDING_MODELS
885 .iter()
886 .find(|m| m.cloud == cloud && m.public_id == model_id)
887}
888
889static DIRECT_ANTHROPIC_MODELS: &[DirectAnthropicModel] = &[
893 DirectAnthropicModel {
894 public_id: "claude-opus-5",
895 upstream_id: "claude-opus-5",
896 },
897 DirectAnthropicModel {
898 public_id: "claude-sonnet-5",
899 upstream_id: "claude-sonnet-5",
900 },
901 DirectAnthropicModel {
902 public_id: "claude-opus-4.8",
903 upstream_id: "claude-opus-4-8",
904 },
905 DirectAnthropicModel {
906 public_id: "claude-opus-4.7",
907 upstream_id: "claude-opus-4-7",
908 },
909 DirectAnthropicModel {
910 public_id: "claude-opus-4.6",
911 upstream_id: "claude-opus-4-6",
912 },
913 DirectAnthropicModel {
914 public_id: "claude-opus-4.5",
915 upstream_id: "claude-opus-4-5",
916 },
917 DirectAnthropicModel {
918 public_id: "claude-sonnet-4.6",
919 upstream_id: "claude-sonnet-4-6",
920 },
921 DirectAnthropicModel {
922 public_id: "claude-sonnet-4.5",
923 upstream_id: "claude-sonnet-4-5-20250929",
924 },
925 DirectAnthropicModel {
926 public_id: "claude-haiku-4.5",
927 upstream_id: "claude-haiku-4-5-20251001",
928 },
929 DirectAnthropicModel {
930 public_id: "claude-fable-5",
931 upstream_id: "claude-fable-5",
932 },
933];
934
935static DIRECT_OPENAI_MODELS: &[DirectOpenAiModel] = &[
945 DirectOpenAiModel {
946 public_id: "gpt-5.6-sol",
947 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
948 },
949 DirectOpenAiModel {
950 public_id: "gpt-5.6-terra",
951 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
952 },
953 DirectOpenAiModel {
954 public_id: "gpt-5.6-luna",
955 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
956 },
957 DirectOpenAiModel {
958 public_id: "gpt-5.5",
959 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
960 },
961 DirectOpenAiModel {
962 public_id: "gpt-5.4",
963 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
964 },
965 DirectOpenAiModel {
966 public_id: "gpt-4.1",
967 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
968 },
969 DirectOpenAiModel {
970 public_id: "gpt-4.1-mini",
971 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
972 },
973 DirectOpenAiModel {
974 public_id: "gpt-4o-mini",
975 client_apis: &[ClientApi::OpenAiChatCompletions, ClientApi::OpenAiResponses],
976 },
977];
978
979static DIRECT_DATABRICKS_MODELS: &[DirectDatabricksModel] = &[
986 DirectDatabricksModel {
987 public_id: "gpt-5.6-sol",
988 upstream: DirectDatabricksUpstream::ServingEndpointChat {
989 endpoint: "databricks-gpt-5-6-sol",
990 },
991 },
992 DirectDatabricksModel {
993 public_id: "gpt-5.6-terra",
994 upstream: DirectDatabricksUpstream::ServingEndpointChat {
995 endpoint: "databricks-gpt-5-6-terra",
996 },
997 },
998 DirectDatabricksModel {
999 public_id: "gpt-5.6-luna",
1000 upstream: DirectDatabricksUpstream::ServingEndpointChat {
1001 endpoint: "databricks-gpt-5-6-luna",
1002 },
1003 },
1004 DirectDatabricksModel {
1005 public_id: "gpt-5.5",
1006 upstream: DirectDatabricksUpstream::ServingEndpointChat {
1007 endpoint: "databricks-gpt-5-5",
1008 },
1009 },
1010 DirectDatabricksModel {
1011 public_id: "gpt-5.4",
1012 upstream: DirectDatabricksUpstream::ServingEndpointChat {
1013 endpoint: "databricks-gpt-5-4",
1014 },
1015 },
1016 DirectDatabricksModel {
1017 public_id: "claude-haiku-4.5",
1018 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1019 service: "system.ai.claude-haiku-4-5",
1020 },
1021 },
1022 DirectDatabricksModel {
1023 public_id: "claude-opus-5",
1024 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1025 service: "system.ai.claude-opus-5",
1026 },
1027 },
1028 DirectDatabricksModel {
1029 public_id: "claude-sonnet-5",
1030 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1031 service: "system.ai.claude-sonnet-5",
1032 },
1033 },
1034 DirectDatabricksModel {
1035 public_id: "claude-sonnet-4.6",
1036 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1037 service: "system.ai.claude-sonnet-4-6",
1038 },
1039 },
1040 DirectDatabricksModel {
1041 public_id: "claude-sonnet-4.5",
1042 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1043 service: "system.ai.claude-sonnet-4-5",
1044 },
1045 },
1046 DirectDatabricksModel {
1047 public_id: "claude-fable-5",
1048 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1049 service: "system.ai.claude-fable-5",
1050 },
1051 },
1052 DirectDatabricksModel {
1053 public_id: "claude-opus-4.8",
1054 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1055 service: "system.ai.claude-opus-4-8",
1056 },
1057 },
1058 DirectDatabricksModel {
1059 public_id: "claude-opus-4.7",
1060 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1061 service: "system.ai.claude-opus-4-7",
1062 },
1063 },
1064 DirectDatabricksModel {
1065 public_id: "claude-opus-4.6",
1066 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1067 service: "system.ai.claude-opus-4-6",
1068 },
1069 },
1070 DirectDatabricksModel {
1071 public_id: "claude-opus-4.5",
1072 upstream: DirectDatabricksUpstream::ModelServiceMessages {
1073 service: "system.ai.claude-opus-4-5",
1074 },
1075 },
1076 DirectDatabricksModel {
1077 public_id: "gemini-3.5-flash",
1078 upstream: DirectDatabricksUpstream::ModelServiceChat {
1079 service: "system.ai.gemini-3-5-flash",
1080 },
1081 },
1082 DirectDatabricksModel {
1083 public_id: "gemini-3.1-flash-lite",
1084 upstream: DirectDatabricksUpstream::ModelServiceChat {
1085 service: "system.ai.gemini-3-1-flash-lite",
1086 },
1087 },
1088 DirectDatabricksModel {
1089 public_id: "gpt-oss-120b",
1090 upstream: DirectDatabricksUpstream::ServingEndpointChat {
1091 endpoint: "databricks-gpt-oss-120b",
1092 },
1093 },
1094 DirectDatabricksModel {
1095 public_id: "gpt-oss-20b",
1096 upstream: DirectDatabricksUpstream::ServingEndpointChat {
1097 endpoint: "databricks-gpt-oss-20b",
1098 },
1099 },
1100 DirectDatabricksModel {
1101 public_id: "gemma-3-12b",
1102 upstream: DirectDatabricksUpstream::ModelServiceChat {
1103 service: "system.ai.gemma-3-12b",
1104 },
1105 },
1106];
1107
1108#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1110pub struct ResponsesTarget {
1111 pub upstream_id: &'static str,
1113 pub path: &'static str,
1116}
1117
1118static RESPONSES_UPSTREAM: &[(&str, ResponsesTarget)] = &[
1123 (
1124 "gpt-oss-20b",
1125 ResponsesTarget {
1126 upstream_id: "openai.gpt-oss-20b",
1127 path: "/v1/responses",
1128 },
1129 ),
1130 (
1131 "gpt-oss-120b",
1132 ResponsesTarget {
1133 upstream_id: "openai.gpt-oss-120b",
1134 path: "/v1/responses",
1135 },
1136 ),
1137 (
1138 "gpt-5.6-sol",
1139 ResponsesTarget {
1140 upstream_id: "openai.gpt-5.6-sol",
1141 path: "/openai/v1/responses",
1142 },
1143 ),
1144 (
1145 "gpt-5.6-terra",
1146 ResponsesTarget {
1147 upstream_id: "openai.gpt-5.6-terra",
1148 path: "/openai/v1/responses",
1149 },
1150 ),
1151 (
1152 "gpt-5.6-luna",
1153 ResponsesTarget {
1154 upstream_id: "openai.gpt-5.6-luna",
1155 path: "/openai/v1/responses",
1156 },
1157 ),
1158 (
1159 "gpt-5.5",
1160 ResponsesTarget {
1161 upstream_id: "openai.gpt-5.5",
1162 path: "/openai/v1/responses",
1163 },
1164 ),
1165 (
1166 "gpt-5.4",
1167 ResponsesTarget {
1168 upstream_id: "openai.gpt-5.4",
1169 path: "/openai/v1/responses",
1170 },
1171 ),
1172];
1173
1174pub fn responses_target(public_id: &str) -> Option<ResponsesTarget> {
1177 RESPONSES_UPSTREAM
1178 .iter()
1179 .find(|(public, _)| *public == public_id)
1180 .map(|(_, target)| *target)
1181}
1182
1183pub fn models_for(cloud: Platform) -> Vec<&'static CatalogModel> {
1184 CATALOG.iter().filter(|m| m.cloud == cloud).collect()
1185}
1186
1187pub fn direct_anthropic_models() -> Vec<&'static DirectAnthropicModel> {
1188 DIRECT_ANTHROPIC_MODELS.iter().collect()
1189}
1190
1191pub fn resolve_direct_anthropic(public_id: &str) -> Option<&'static DirectAnthropicModel> {
1192 DIRECT_ANTHROPIC_MODELS
1193 .iter()
1194 .find(|model| model.public_id == public_id)
1195}
1196
1197pub fn direct_openai_models() -> Vec<&'static DirectOpenAiModel> {
1198 DIRECT_OPENAI_MODELS.iter().collect()
1199}
1200
1201pub fn resolve_direct_openai(public_id: &str) -> Option<&'static DirectOpenAiModel> {
1202 DIRECT_OPENAI_MODELS
1203 .iter()
1204 .find(|model| model.public_id == public_id)
1205}
1206
1207pub fn direct_databricks_models() -> Vec<&'static DirectDatabricksModel> {
1208 DIRECT_DATABRICKS_MODELS.iter().collect()
1209}
1210
1211pub fn resolve_direct_databricks(public_id: &str) -> Option<&'static DirectDatabricksModel> {
1212 DIRECT_DATABRICKS_MODELS
1213 .iter()
1214 .find(|model| model.public_id == public_id)
1215}
1216
1217pub fn lookup(public_id: &str) -> Option<&'static CatalogModel> {
1222 CATALOG.iter().find(|m| m.public_id == public_id)
1223}
1224
1225fn lookup_for(public_id: &str, cloud: Platform) -> Option<&'static CatalogModel> {
1226 CATALOG
1227 .iter()
1228 .find(|m| m.public_id == public_id && m.cloud == cloud)
1229}
1230
1231pub fn resolve_for(model_id: &str, cloud: Platform) -> Option<&'static CatalogModel> {
1236 lookup_for(model_id, cloud).or_else(|| lookup_for(&canonical_public_id(model_id), cloud))
1237}
1238
1239pub fn resolve(model_id: &str) -> Option<&'static CatalogModel> {
1254 lookup(model_id).or_else(|| lookup(&canonical_public_id(model_id)))
1255}
1256
1257fn canonical_public_id(model_id: &str) -> String {
1258 let mut id = model_id;
1259 if let Some(pos) = id.rfind("anthropic.") {
1260 id = &id[pos + "anthropic.".len()..];
1261 }
1262 id = id.split_once('@').map_or(id, |(base, _)| base);
1264 id = strip_invoke_version(id);
1265 id = strip_release_date(id);
1266 dot_minor_version(id)
1267}
1268
1269fn strip_invoke_version(id: &str) -> &str {
1271 let base = id.split_once(':').map_or(id, |(base, _)| base);
1272 match base.rsplit_once("-v") {
1273 Some((stem, digits))
1274 if !digits.is_empty() && digits.bytes().all(|b| b.is_ascii_digit()) =>
1275 {
1276 stem
1277 }
1278 _ => base,
1279 }
1280}
1281
1282fn strip_release_date(id: &str) -> &str {
1284 match id.rsplit_once('-') {
1285 Some((stem, date))
1286 if date.len() == 8
1287 && date.starts_with("20")
1288 && date.bytes().all(|b| b.is_ascii_digit()) =>
1289 {
1290 stem
1291 }
1292 _ => id,
1293 }
1294}
1295
1296fn dot_minor_version(id: &str) -> String {
1300 let Some((stem, minor)) = id.rsplit_once('-') else {
1301 return id.to_string();
1302 };
1303 let Some((prefix, major)) = stem.rsplit_once('-') else {
1304 return id.to_string();
1305 };
1306 let both_numeric = !major.is_empty()
1307 && !minor.is_empty()
1308 && major.bytes().all(|b| b.is_ascii_digit())
1309 && minor.bytes().all(|b| b.is_ascii_digit());
1310 if both_numeric {
1311 format!("{prefix}-{major}.{minor}")
1312 } else {
1313 id.to_string()
1314 }
1315}
1316
1317pub fn azure_deployments() -> Vec<(&'static str, &'static str, &'static str, i32)> {
1319 AZURE_DEPLOYMENTS.to_vec()
1320}
1321
1322#[cfg(test)]
1323mod tests {
1324 #[test]
1325 fn bedrock_geo_routes_non_us_regions_via_global() {
1326 assert_eq!(bedrock_geo("us-east-2"), "us");
1327 assert_eq!(bedrock_geo("us-west-2"), "us");
1328 assert_eq!(bedrock_geo("us-gov-west-1"), "us-gov");
1329 assert_eq!(bedrock_geo("eu-west-1"), "global");
1330 assert_eq!(bedrock_geo("ap-southeast-2"), "global");
1331 assert_eq!(bedrock_geo("ca-central-1"), "global");
1332 assert_eq!(bedrock_geo("sa-east-1"), "global");
1333 assert_eq!(bedrock_geo("mx-central-1"), "global");
1334 }
1335
1336 #[test]
1337 fn inference_profile_id_prefixes_the_regions_geo() {
1338 assert_eq!(
1339 bedrock_inference_profile_id("us-west-2", "anthropic.claude-sonnet-5"),
1340 "us.anthropic.claude-sonnet-5"
1341 );
1342 assert_eq!(
1343 bedrock_inference_profile_id("eu-west-1", "anthropic.claude-sonnet-5"),
1344 "global.anthropic.claude-sonnet-5"
1345 );
1346 }
1347
1348 #[test]
1352 fn public_ids_are_unique_per_cloud() {
1353 let mut seen = std::collections::HashSet::new();
1354 for model in super::CATALOG {
1355 assert!(
1356 seen.insert((model.cloud, model.public_id)),
1357 "public id '{}' appears more than once under {:?}",
1358 model.public_id,
1359 model.cloud
1360 );
1361 }
1362 }
1363
1364 #[test]
1365 fn direct_anthropic_aliases_are_unique_and_round_trip() {
1366 let mut public_ids = std::collections::HashSet::new();
1367 let mut upstream_ids = std::collections::HashSet::new();
1368 for model in DIRECT_ANTHROPIC_MODELS {
1369 assert!(public_ids.insert(model.public_id));
1370 assert!(upstream_ids.insert(model.upstream_id));
1371 assert_eq!(
1372 resolve_direct_anthropic(model.public_id)
1373 .expect("direct model must resolve")
1374 .upstream_id,
1375 model.upstream_id
1376 );
1377 assert_ne!(model.display_name(), model.public_id);
1378 }
1379 assert!(resolve_direct_anthropic("claude-not-real").is_none());
1380 }
1381
1382 #[test]
1383 fn direct_openai_models_are_unique_and_have_qualified_apis() {
1384 let mut public_ids = std::collections::HashSet::new();
1385 for model in DIRECT_OPENAI_MODELS {
1386 assert!(public_ids.insert(model.public_id));
1387 assert!(!model.client_apis.is_empty());
1388 assert_eq!(
1389 resolve_direct_openai(model.public_id)
1390 .expect("direct model must resolve")
1391 .client_apis,
1392 model.client_apis
1393 );
1394 }
1395 assert!(resolve_direct_openai("text-embedding-3-small").is_none());
1396 assert!(resolve_direct_openai("gpt-image-1").is_none());
1397 }
1398
1399 #[test]
1400 fn direct_databricks_models_are_unique_and_resolve_to_provider_ids() {
1401 let mut public_ids = std::collections::HashSet::new();
1402 for model in DIRECT_DATABRICKS_MODELS {
1403 assert!(public_ids.insert(model.public_id));
1404 let upstream_id = model.upstream.model_id();
1405 assert!(
1406 upstream_id.starts_with("databricks-") || upstream_id.starts_with("system.ai.")
1407 );
1408 assert_eq!(
1409 resolve_direct_databricks(model.public_id)
1410 .expect("direct Databricks model must resolve")
1411 .upstream,
1412 model.upstream
1413 );
1414 }
1415 assert!(resolve_direct_databricks("bge-large-en").is_none());
1416 assert!(resolve_direct_databricks("databricks-genie").is_none());
1417 assert_eq!(
1418 resolve_direct_databricks("claude-opus-5")
1419 .expect("Claude Opus 5 must resolve")
1420 .upstream
1421 .model_id(),
1422 "system.ai.claude-opus-5"
1423 );
1424 assert_eq!(
1425 resolve_direct_databricks("gpt-oss-120b")
1426 .expect("GPT-OSS 120B must resolve")
1427 .upstream,
1428 DirectDatabricksUpstream::ServingEndpointChat {
1429 endpoint: "databricks-gpt-oss-120b"
1430 }
1431 );
1432 }
1433
1434 use super::*;
1435
1436 #[test]
1437 fn resolve_accepts_anthropic_native_spellings() {
1438 assert_eq!(
1440 resolve("claude-haiku-4-5").unwrap().public_id,
1441 "claude-haiku-4.5"
1442 );
1443 assert_eq!(
1444 resolve("claude-sonnet-4-5-20250929").unwrap().public_id,
1445 "claude-sonnet-4.5"
1446 );
1447 assert_eq!(
1449 resolve("us.anthropic.claude-haiku-4-5-20251001-v1:0")
1450 .unwrap()
1451 .public_id,
1452 "claude-haiku-4.5"
1453 );
1454 assert_eq!(
1455 resolve("anthropic.claude-opus-4-6-v1").unwrap().public_id,
1456 "claude-opus-4.6"
1457 );
1458 assert_eq!(
1460 resolve("claude-sonnet-5").unwrap().public_id,
1461 "claude-sonnet-5"
1462 );
1463 assert_eq!(
1465 resolve("claude-opus-4.8").unwrap().public_id,
1466 "claude-opus-4.8"
1467 );
1468 assert_eq!(resolve("gpt-oss-20b").unwrap().public_id, "gpt-oss-20b");
1469 assert!(resolve("claude-nonexistent-9-9").is_none());
1471 assert!(resolve("gpt-5").is_none());
1472 }
1473
1474 #[test]
1475 fn aws_has_openai_and_anthropic_with_plain_ids() {
1476 let aws = models_for(Platform::Aws);
1477 assert!(!aws.is_empty());
1478 assert!(aws
1479 .iter()
1480 .any(|m| m.public_id == "gpt-oss-20b" && m.provider_api == ProviderApi::OpenAi));
1481 assert!(
1482 aws.iter().any(|m| m.provider_api == ProviderApi::Anthropic),
1483 "Claude must be included via the Anthropic protocol"
1484 );
1485 assert!(aws.iter().all(|m| !m.upstream_id.starts_with("us.")));
1487 }
1488
1489 #[test]
1490 fn resolve_for_scopes_to_cloud() {
1491 let aws = resolve_for("claude-opus-4.8", Platform::Aws).expect("aws claude");
1494 assert_eq!(aws.upstream_id, "anthropic.claude-opus-4-8");
1495 let gcp = resolve_for("claude-opus-4.8", Platform::Gcp).expect("gcp claude");
1496 assert_eq!(gcp.upstream_id, "claude-opus-4-8");
1497 assert_eq!(gcp.provider_api, ProviderApi::Anthropic);
1498 let dated = resolve_for("claude-haiku-4-5-20251001", Platform::Gcp).expect("dated id");
1501 assert_eq!(dated.upstream_id, "claude-haiku-4-5@20251001");
1502 let vertex = resolve_for("claude-sonnet-4-5@20250929", Platform::Gcp).expect("vertex id");
1505 assert_eq!(vertex.upstream_id, "claude-sonnet-4-5@20250929");
1506 assert!(resolve_for("gemini-2.5-pro", Platform::Aws).is_none());
1508 assert!(resolve_for("gpt-4.1", Platform::Gcp).is_none());
1509 }
1510
1511 #[test]
1512 fn lookup_round_trips() {
1513 let m = lookup("gpt-oss-20b").expect("known model");
1514 assert_eq!(m.cloud, Platform::Aws);
1515 assert_eq!(m.provider_api, ProviderApi::OpenAi);
1516 assert_eq!(m.upstream_id, "openai.gpt-oss-20b-1:0");
1517
1518 let c = lookup("claude-opus-4.8").expect("claude known");
1519 assert_eq!(c.provider_api, ProviderApi::Anthropic);
1520
1521 assert!(lookup("nonexistent-model").is_none());
1522 }
1523
1524 #[test]
1525 fn azure_deployments_map_to_catalog() {
1526 assert!(!azure_deployments().is_empty());
1527 for (deployment, ..) in azure_deployments() {
1528 assert!(
1529 models_for(Platform::Azure)
1530 .iter()
1531 .any(|m| m.upstream_id == deployment)
1532 || resolve_embedding_for(deployment, Platform::Azure).is_some(),
1533 "azure deployment {deployment} must map to a catalog model"
1534 );
1535 }
1536 }
1537
1538 #[test]
1539 fn embeddings_resolve_only_on_the_cloud_that_serves_them() {
1540 let m = resolve_embedding_for("text-embedding-3-large", Platform::Azure).unwrap();
1541 assert_eq!(m.upstream_id, "text-embedding-3-large");
1542 assert!(resolve_embedding_for("text-embedding-3-large", Platform::Aws).is_none());
1543 assert!(lookup("text-embedding-3-large").is_none());
1545 }
1546
1547 #[test]
1548 fn api_kinds_have_stable_wire_names() {
1549 assert_eq!(
1550 serde_json::to_string(&ProviderApi::OpenAi).unwrap(),
1551 "\"openai\""
1552 );
1553 assert_eq!(
1554 serde_json::to_string(&ProviderApi::Anthropic).unwrap(),
1555 "\"anthropic\""
1556 );
1557 assert_eq!(
1558 serde_json::to_string(&ProviderApi::OpenAiResponses).unwrap(),
1559 "\"openairesponses\""
1560 );
1561 assert_eq!(
1562 serde_json::to_string(&ClientApi::OpenAiChatCompletions).unwrap(),
1563 "\"open-ai-chat-completions\""
1564 );
1565 assert_eq!(
1566 serde_json::to_string(&ClientApi::OpenAiResponses).unwrap(),
1567 "\"open-ai-responses\""
1568 );
1569 assert_eq!(
1570 serde_json::to_string(&ClientApi::AnthropicMessages).unwrap(),
1571 "\"anthropic-messages\""
1572 );
1573 }
1574
1575 #[test]
1576 fn client_apis_are_explicit_and_non_empty() {
1577 for model in CATALOG {
1578 assert!(
1579 !model.client_apis.is_empty(),
1580 "'{}' has no supported client API",
1581 model.public_id
1582 );
1583 }
1584
1585 let gpt_oss = resolve_for("gpt-oss-20b", Platform::Aws).unwrap();
1586 assert!(gpt_oss
1587 .client_apis
1588 .contains(&ClientApi::OpenAiChatCompletions));
1589 assert!(gpt_oss.client_apis.contains(&ClientApi::OpenAiResponses));
1590 }
1591
1592 #[test]
1593 fn every_model_has_provider_display_name_and_activation() {
1594 for m in CATALOG {
1595 assert_ne!(
1596 m.provider(),
1597 "unknown",
1598 "no provider mapping for '{}'",
1599 m.public_id
1600 );
1601 assert_ne!(
1602 m.display_name(),
1603 m.public_id,
1604 "no curated display_name for '{}'",
1605 m.public_id
1606 );
1607 let is_claude = m.public_id.starts_with("claude");
1609 match m.activation() {
1610 Activation::OutOfBox => {
1611 assert!(
1612 !is_claude,
1613 "'{}' (Claude) must require a one-time step",
1614 m.public_id
1615 )
1616 }
1617 Activation::RequiresOneTimeStep(summary) => {
1618 assert!(is_claude, "'{}' must be out of the box", m.public_id);
1619 assert!(
1620 !summary.is_empty(),
1621 "'{}' step summary is empty",
1622 m.public_id
1623 );
1624 }
1625 }
1626 }
1627 }
1628
1629 #[test]
1633 fn only_claude_ids_speak_the_anthropic_protocol() {
1634 for m in CATALOG {
1635 assert_eq!(
1636 m.provider_api == ProviderApi::Anthropic,
1637 m.public_id.starts_with("claude"),
1638 "'{}' is {:?} but its id says otherwise",
1639 m.public_id,
1640 m.provider_api
1641 );
1642 }
1643 }
1644}