alien-core 3.3.3

Deploy software into your customers' cloud accounts and keep it fully managed
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
//! Curated, per-cloud model catalog for the AI gateway.
//!
//! Single source of truth for which public model ids each cloud exposes, the
//! upstream id the gateway forwards, and the wire protocol of the model's native
//! endpoint. Backs `getAvailableModels()` and the gateway's `/v1/models`, and the
//! Azure controller deploys the Azure entries as named deployments at provision
//! time (see `azure_deployments`).
//!
//! A model is includable only if its cloud serves it over a protocol the client
//! SDK already speaks (OpenAI Chat Completions or Anthropic Messages), so the
//! gateway forwards the request body untranslated.

use crate::Platform;
use serde::{Deserialize, Serialize};

/// The upstream wire protocol a model speaks. The gateway forwards to the
/// matching native endpoint; the client SDK is responsible for speaking it.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Protocol {
    /// OpenAI Chat Completions (`/v1/chat/completions`).
    OpenAi,
    /// Anthropic Messages (`/v1/messages`).
    Anthropic,
    /// OpenAI Responses on bedrock-mantle. The only API the GPT-5 family serves;
    /// the exact path is per-model, see `RESPONSES_UPSTREAM`.
    OpenAiResponses,
}

/// The one-time action, if any, a customer must take in the cloud provider before
/// the gateway can invoke a model. Static per (provider, cloud), surfaced in docs
/// and the example README. Distinct from runtime availability, which
/// `getAvailableModels` probes live per deployment.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Activation {
    /// Enabled by default; nothing for the customer to do (quota still applies).
    OutOfBox,
    /// Needs a one-time customer action first; the string says what.
    RequiresOneTimeStep(&'static str),
}

/// One curated model: the public id an app requests, the cloud that serves it,
/// the upstream id the gateway forwards (for Azure this is the deployment name),
/// and the protocol of its native endpoint.
#[derive(Debug, Clone)]
pub struct CatalogModel {
    pub public_id: &'static str,
    pub cloud: Platform,
    pub upstream_id: &'static str,
    pub protocol: Protocol,
}

impl CatalogModel {
    /// The model's publisher, for grouping in a picker. Derived from the public id,
    /// so the same public id reports the same provider on every cloud.
    pub fn provider(&self) -> &'static str {
        let id = self.public_id;
        if id.starts_with("claude") {
            "anthropic"
        } else if id.starts_with("gpt") || id == "model-router" {
            "openai"
        } else if id.starts_with("gemini") || id.starts_with("gemma") {
            "google"
        } else if id.starts_with("qwen") {
            "qwen"
        } else if id.starts_with("deepseek") {
            "deepseek"
        } else if id.starts_with("mistral")
            || id.starts_with("devstral")
            || id.starts_with("magistral")
            || id.starts_with("ministral")
        {
            "mistral"
        } else if id.starts_with("minimax") {
            "minimax"
        } else if id.starts_with("kimi") {
            "moonshotai"
        } else if id.starts_with("nemotron") {
            "nvidia"
        } else if id.starts_with("glm") {
            "zai"
        } else if id.starts_with("palmyra") {
            "writer"
        } else {
            "unknown"
        }
    }

    /// A human label for a model picker. Curated per id rather than derived so the
    /// acronyms (GPT, OSS, GLM, VL) and versions read correctly.
    pub fn display_name(&self) -> &'static str {
        match self.public_id {
            "gpt-5.6-sol" => "GPT-5.6 Sol",
            "gpt-5.6-terra" => "GPT-5.6 Terra",
            "gpt-5.6-luna" => "GPT-5.6 Luna",
            "gpt-5.5" => "GPT-5.5",
            "gpt-5.4" => "GPT-5.4",
            "gpt-oss-20b" => "GPT-OSS 20B",
            "gpt-oss-120b" => "GPT-OSS 120B",
            "gpt-oss-safeguard-20b" => "GPT-OSS Safeguard 20B",
            "gpt-oss-safeguard-120b" => "GPT-OSS Safeguard 120B",
            "deepseek-v3.2" => "DeepSeek V3.2",
            "qwen3-32b" => "Qwen3 32B",
            "qwen3-coder-30b" => "Qwen3 Coder 30B",
            "qwen3-coder-next" => "Qwen3 Coder Next",
            "qwen3-next-80b" => "Qwen3 Next 80B",
            "qwen3-vl-235b" => "Qwen3 VL 235B",
            "mistral-large-3" => "Mistral Large 3",
            "devstral-2" => "Devstral 2",
            "magistral-small" => "Magistral Small",
            "ministral-3-14b" => "Ministral 3 14B",
            "ministral-3-8b" => "Ministral 3 8B",
            "ministral-3-3b" => "Ministral 3 3B",
            "minimax-m2" => "MiniMax M2",
            "minimax-m2.1" => "MiniMax M2.1",
            "minimax-m2.5" => "MiniMax M2.5",
            "kimi-k2.5" => "Kimi K2.5",
            "nemotron-nano-9b" => "Nemotron Nano 9B",
            "nemotron-nano-12b" => "Nemotron Nano 12B",
            "nemotron-nano-3-30b" => "Nemotron Nano 3 30B",
            "nemotron-super-3-120b" => "Nemotron Super 3 120B",
            "gemma-3-4b" => "Gemma 3 4B",
            "gemma-3-12b" => "Gemma 3 12B",
            "gemma-3-27b" => "Gemma 3 27B",
            "glm-4.7" => "GLM 4.7",
            "glm-4.7-flash" => "GLM 4.7 Flash",
            "glm-5" => "GLM 5",
            "palmyra-vision-7b" => "Palmyra Vision 7B",
            "claude-opus-5" => "Claude Opus 5",
            "claude-sonnet-5" => "Claude Sonnet 5",
            "claude-opus-4.8" => "Claude Opus 4.8",
            "claude-opus-4.7" => "Claude Opus 4.7",
            "claude-opus-4.6" => "Claude Opus 4.6",
            "claude-opus-4.5" => "Claude Opus 4.5",
            "claude-opus-4.1" => "Claude Opus 4.1",
            "claude-sonnet-4.6" => "Claude Sonnet 4.6",
            "claude-sonnet-4.5" => "Claude Sonnet 4.5",
            "claude-haiku-4.5" => "Claude Haiku 4.5",
            "claude-fable-5" => "Claude Fable 5",
            "claude-mythos-5" => "Claude Mythos 5",
            "claude-sonnet-4" => "Claude Sonnet 4",
            "claude-3-haiku" => "Claude 3 Haiku",
            "gemini-2.5-pro" => "Gemini 2.5 Pro",
            "gemini-2.5-flash" => "Gemini 2.5 Flash",
            "gemini-2.5-flash-lite" => "Gemini 2.5 Flash Lite",
            "gemini-3.5-flash" => "Gemini 3.5 Flash",
            "gemini-3.1-flash-lite" => "Gemini 3.1 Flash Lite",
            "gpt-4.1" => "GPT-4.1",
            "gpt-4o-mini" => "GPT-4o mini",
            "model-router" => "Model Router",
            other => other,
        }
    }

    /// The one-time enablement step for this model on its cloud, if any. Only Claude
    /// needs one today, and the step differs per cloud.
    pub fn activation(&self) -> Activation {
        if !self.public_id.starts_with("claude") {
            return Activation::OutOfBox;
        }
        match self.cloud {
            Platform::Aws => Activation::RequiresOneTimeStep(
                "Submit the one-time Anthropic use-case form in the Bedrock console.",
            ),
            Platform::Gcp => Activation::RequiresOneTimeStep(
                "Enable Claude in Vertex AI Model Garden and accept Anthropic's terms of service, one-time, in the Google Cloud console.",
            ),
            Platform::Azure => Activation::RequiresOneTimeStep(
                "Accept the Marketplace terms and create the Claude deployment in the Microsoft Foundry portal (one-time).",
            ),
            _ => Activation::OutOfBox,
        }
    }
}

static CATALOG: &[CatalogModel] = &[
    // AWS Bedrock over `/openai/v1` chat completions. The plain Bedrock model id,
    // not the `us.*` cross-region inference profile — that endpoint rejects it.
    // Invoke/Converse-only models (older Llama/Mistral-v0/Nova) can't be served here.
    // The GPT-5 family is Responses-only: chat completions, converse and invoke are
    // all unavailable, so `upstream_id` here is the mantle id and the chat probe
    // would reject them.
    CatalogModel { public_id: "gpt-5.6-sol", cloud: Platform::Aws, upstream_id: "openai.gpt-5.6-sol", protocol: Protocol::OpenAiResponses },
    CatalogModel { public_id: "gpt-5.6-terra", cloud: Platform::Aws, upstream_id: "openai.gpt-5.6-terra", protocol: Protocol::OpenAiResponses },
    CatalogModel { public_id: "gpt-5.6-luna", cloud: Platform::Aws, upstream_id: "openai.gpt-5.6-luna", protocol: Protocol::OpenAiResponses },
    CatalogModel { public_id: "gpt-5.5", cloud: Platform::Aws, upstream_id: "openai.gpt-5.5", protocol: Protocol::OpenAiResponses },
    CatalogModel { public_id: "gpt-5.4", cloud: Platform::Aws, upstream_id: "openai.gpt-5.4", protocol: Protocol::OpenAiResponses },
    CatalogModel { public_id: "gpt-oss-20b", cloud: Platform::Aws, upstream_id: "openai.gpt-oss-20b-1:0", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gpt-oss-120b", cloud: Platform::Aws, upstream_id: "openai.gpt-oss-120b-1:0", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gpt-oss-safeguard-20b", cloud: Platform::Aws, upstream_id: "openai.gpt-oss-safeguard-20b", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gpt-oss-safeguard-120b", cloud: Platform::Aws, upstream_id: "openai.gpt-oss-safeguard-120b", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "deepseek-v3.2", cloud: Platform::Aws, upstream_id: "deepseek.v3.2", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "qwen3-32b", cloud: Platform::Aws, upstream_id: "qwen.qwen3-32b-v1:0", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "qwen3-coder-30b", cloud: Platform::Aws, upstream_id: "qwen.qwen3-coder-30b-a3b-v1:0", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "qwen3-coder-next", cloud: Platform::Aws, upstream_id: "qwen.qwen3-coder-next", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "qwen3-next-80b", cloud: Platform::Aws, upstream_id: "qwen.qwen3-next-80b-a3b", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "qwen3-vl-235b", cloud: Platform::Aws, upstream_id: "qwen.qwen3-vl-235b-a22b", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "mistral-large-3", cloud: Platform::Aws, upstream_id: "mistral.mistral-large-3-675b-instruct", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "devstral-2", cloud: Platform::Aws, upstream_id: "mistral.devstral-2-123b", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "magistral-small", cloud: Platform::Aws, upstream_id: "mistral.magistral-small-2509", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "ministral-3-14b", cloud: Platform::Aws, upstream_id: "mistral.ministral-3-14b-instruct", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "ministral-3-8b", cloud: Platform::Aws, upstream_id: "mistral.ministral-3-8b-instruct", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "ministral-3-3b", cloud: Platform::Aws, upstream_id: "mistral.ministral-3-3b-instruct", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "minimax-m2", cloud: Platform::Aws, upstream_id: "minimax.minimax-m2", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "minimax-m2.1", cloud: Platform::Aws, upstream_id: "minimax.minimax-m2.1", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "minimax-m2.5", cloud: Platform::Aws, upstream_id: "minimax.minimax-m2.5", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "kimi-k2.5", cloud: Platform::Aws, upstream_id: "moonshotai.kimi-k2.5", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "nemotron-nano-9b", cloud: Platform::Aws, upstream_id: "nvidia.nemotron-nano-9b-v2", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "nemotron-nano-12b", cloud: Platform::Aws, upstream_id: "nvidia.nemotron-nano-12b-v2", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "nemotron-nano-3-30b", cloud: Platform::Aws, upstream_id: "nvidia.nemotron-nano-3-30b", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "nemotron-super-3-120b", cloud: Platform::Aws, upstream_id: "nvidia.nemotron-super-3-120b", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gemma-3-4b", cloud: Platform::Aws, upstream_id: "google.gemma-3-4b-it", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gemma-3-12b", cloud: Platform::Aws, upstream_id: "google.gemma-3-12b-it", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gemma-3-27b", cloud: Platform::Aws, upstream_id: "google.gemma-3-27b-it", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "glm-4.7", cloud: Platform::Aws, upstream_id: "zai.glm-4.7", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "glm-4.7-flash", cloud: Platform::Aws, upstream_id: "zai.glm-4.7-flash", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "glm-5", cloud: Platform::Aws, upstream_id: "zai.glm-5", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "palmyra-vision-7b", cloud: Platform::Aws, upstream_id: "writer.palmyra-vision-7b", protocol: Protocol::OpenAi },
    // AWS Bedrock, Claude over classic InvokeModel (the Anthropic Messages body is
    // the InvokeModel body; the model travels in the URL). `upstream_id` is the plain
    // Bedrock model id; the gateway prepends the region's cross-region inference-profile
    // geo prefix (`us.`/`eu.`/`apac.`) at request time, since Claude is invocable only
    // through a profile. Dated ids (`…-<date>-v1:0`) are required where AWS has no short
    // alias. These need Claude model access granted on the deployment's account.
    CatalogModel { public_id: "claude-opus-5", cloud: Platform::Aws, upstream_id: "anthropic.claude-opus-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-5", cloud: Platform::Aws, upstream_id: "anthropic.claude-sonnet-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.8", cloud: Platform::Aws, upstream_id: "anthropic.claude-opus-4-8", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.7", cloud: Platform::Aws, upstream_id: "anthropic.claude-opus-4-7", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.6", cloud: Platform::Aws, upstream_id: "anthropic.claude-opus-4-6-v1", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.5", cloud: Platform::Aws, upstream_id: "anthropic.claude-opus-4-5-20251101-v1:0", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.1", cloud: Platform::Aws, upstream_id: "anthropic.claude-opus-4-1-20250805-v1:0", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-4.6", cloud: Platform::Aws, upstream_id: "anthropic.claude-sonnet-4-6", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-4.5", cloud: Platform::Aws, upstream_id: "anthropic.claude-sonnet-4-5-20250929-v1:0", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-haiku-4.5", cloud: Platform::Aws, upstream_id: "anthropic.claude-haiku-4-5-20251001-v1:0", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-fable-5", cloud: Platform::Aws, upstream_id: "anthropic.claude-fable-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-mythos-5", cloud: Platform::Aws, upstream_id: "anthropic.claude-mythos-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-4", cloud: Platform::Aws, upstream_id: "anthropic.claude-sonnet-4-20250514-v1:0", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-3-haiku", cloud: Platform::Aws, upstream_id: "anthropic.claude-3-haiku-20240307-v1:0", protocol: Protocol::Anthropic },
    // GCP Vertex, Gemini. The OpenAI-compatible Vertex endpoint expects the `google/` prefix.
    // The 2.5 family serves in-region; the 3.x models serve on the `global` location.
    CatalogModel { public_id: "gemini-2.5-pro", cloud: Platform::Gcp, upstream_id: "google/gemini-2.5-pro", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gemini-2.5-flash", cloud: Platform::Gcp, upstream_id: "google/gemini-2.5-flash", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gemini-2.5-flash-lite", cloud: Platform::Gcp, upstream_id: "google/gemini-2.5-flash-lite", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gemini-3.5-flash", cloud: Platform::Gcp, upstream_id: "google/gemini-3.5-flash", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gemini-3.1-flash-lite", cloud: Platform::Gcp, upstream_id: "google/gemini-3.1-flash-lite", protocol: Protocol::OpenAi },
    // GCP Vertex, Claude. The upstream id is the Vertex Model Garden id that travels
    // in the `:rawPredict` URL path (`publishers/anthropic/models/<id>`); models past
    // Sonnet 4.5 carry no date suffix, older ones keep an `@<date>` version. Needs
    // Claude model access granted on the deployment's project.
    CatalogModel { public_id: "claude-sonnet-5", cloud: Platform::Gcp, upstream_id: "claude-sonnet-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.8", cloud: Platform::Gcp, upstream_id: "claude-opus-4-8", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.7", cloud: Platform::Gcp, upstream_id: "claude-opus-4-7", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.6", cloud: Platform::Gcp, upstream_id: "claude-opus-4-6", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.5", cloud: Platform::Gcp, upstream_id: "claude-opus-4-5@20251101", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-4.6", cloud: Platform::Gcp, upstream_id: "claude-sonnet-4-6", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-4.5", cloud: Platform::Gcp, upstream_id: "claude-sonnet-4-5@20250929", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-haiku-4.5", cloud: Platform::Gcp, upstream_id: "claude-haiku-4-5@20251001", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-fable-5", cloud: Platform::Gcp, upstream_id: "claude-fable-5", protocol: Protocol::Anthropic },
    // Azure, OpenAI-protocol. The upstream id is the deployment name the controller
    // creates (see AZURE_DEPLOYMENTS); the app requests it by the same id. Azure serves
    // only what is deployed, so this list must stay in sync with AZURE_DEPLOYMENTS.
    CatalogModel { public_id: "gpt-4.1", cloud: Platform::Azure, upstream_id: "gpt-4.1", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "gpt-4o-mini", cloud: Platform::Azure, upstream_id: "gpt-4o-mini", protocol: Protocol::OpenAi },
    CatalogModel { public_id: "model-router", cloud: Platform::Azure, upstream_id: "model-router", protocol: Protocol::OpenAi },
    // Azure, Claude over the Foundry Anthropic endpoint. The upstream id is the
    // Foundry deployment name (defaults to the model id). Unlike the OpenAI list,
    // these are not in AZURE_DEPLOYMENTS: a first Claude deployment requires
    // accepting Azure Marketplace terms, a portal step the controller cannot
    // perform, so Claude deployments are created in the Foundry portal. These stay
    // in the catalog as the deployment-name contract, but the gateway's /v1/models
    // availability probe drops any that the portal step has not created, so the
    // list omits any Claude that Foundry would 404.
    CatalogModel { public_id: "claude-sonnet-5", cloud: Platform::Azure, upstream_id: "claude-sonnet-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.8", cloud: Platform::Azure, upstream_id: "claude-opus-4-8", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.7", cloud: Platform::Azure, upstream_id: "claude-opus-4-7", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.6", cloud: Platform::Azure, upstream_id: "claude-opus-4-6", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-opus-4.5", cloud: Platform::Azure, upstream_id: "claude-opus-4-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-4.6", cloud: Platform::Azure, upstream_id: "claude-sonnet-4-6", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-sonnet-4.5", cloud: Platform::Azure, upstream_id: "claude-sonnet-4-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-haiku-4.5", cloud: Platform::Azure, upstream_id: "claude-haiku-4-5", protocol: Protocol::Anthropic },
    CatalogModel { public_id: "claude-fable-5", cloud: Platform::Azure, upstream_id: "claude-fable-5", protocol: Protocol::Anthropic },
];

/// Azure deployments to create at provision time: (deployment name, model name,
/// model version). The deployment name is the catalog `upstream_id`. The version
/// is validated against the target region's model catalog at deploy time.
static AZURE_DEPLOYMENTS: &[(&str, &str, &str)] = &[
    ("gpt-4.1", "gpt-4.1", "2025-04-14"),
    ("gpt-4o-mini", "gpt-4o-mini", "2024-07-18"),
    ("model-router", "model-router", "2025-11-18"),
];

/// Where a model sits on the bedrock-mantle Responses API.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ResponsesTarget {
    /// The id mantle expects, which drops the InvokeModel version suffix.
    pub upstream_id: &'static str,
    /// Path under the mantle host. The GPT-5 family serves on `/openai/v1/responses`,
    /// the open-weight models on `/v1/responses`.
    pub path: &'static str,
}

/// AWS models servable over the bedrock-mantle OpenAI Responses API. Only a subset
/// of the chat catalog supports Responses at all — Claude is Messages-only and e.g.
/// Qwen rejects it. Kept explicit rather than derived: both the id scheme and the
/// path differ per model family, not by a rule.
static RESPONSES_UPSTREAM: &[(&str, ResponsesTarget)] = &[
    ("gpt-oss-20b", ResponsesTarget { upstream_id: "openai.gpt-oss-20b", path: "/v1/responses" }),
    ("gpt-oss-120b", ResponsesTarget { upstream_id: "openai.gpt-oss-120b", path: "/v1/responses" }),
    ("gpt-5.6-sol", ResponsesTarget { upstream_id: "openai.gpt-5.6-sol", path: "/openai/v1/responses" }),
    ("gpt-5.6-terra", ResponsesTarget { upstream_id: "openai.gpt-5.6-terra", path: "/openai/v1/responses" }),
    ("gpt-5.6-luna", ResponsesTarget { upstream_id: "openai.gpt-5.6-luna", path: "/openai/v1/responses" }),
    ("gpt-5.5", ResponsesTarget { upstream_id: "openai.gpt-5.5", path: "/openai/v1/responses" }),
    ("gpt-5.4", ResponsesTarget { upstream_id: "openai.gpt-5.4", path: "/openai/v1/responses" }),
];

/// The bedrock-mantle Responses target for a public model id, or `None` when the
/// model is not servable over the Responses API.
pub fn responses_target(public_id: &str) -> Option<ResponsesTarget> {
    RESPONSES_UPSTREAM
        .iter()
        .find(|(public, _)| *public == public_id)
        .map(|(_, target)| *target)
}

pub fn models_for(cloud: Platform) -> Vec<&'static CatalogModel> {
    CATALOG.iter().filter(|m| m.cloud == cloud).collect()
}

/// The catalog model for a public id, or `None` if it is not exposed.
///
/// First match: for an id serving on more than one cloud this is the AWS entry;
/// cloud-scoped callers use `lookup_for` via `resolve_for`.
pub fn lookup(public_id: &str) -> Option<&'static CatalogModel> {
    CATALOG.iter().find(|m| m.public_id == public_id)
}

fn lookup_for(public_id: &str, cloud: Platform) -> Option<&'static CatalogModel> {
    CATALOG.iter().find(|m| m.public_id == public_id && m.cloud == cloud)
}

/// The catalog model for a client-sent model id on a specific cloud. A public id
/// can appear once per cloud (Claude serves on more than one), so resolution must
/// scope to the binding's cloud rather than filter a first-match lookup — the
/// first match is another cloud's entry whenever ids overlap.
pub fn resolve_for(model_id: &str, cloud: Platform) -> Option<&'static CatalogModel> {
    lookup_for(model_id, cloud).or_else(|| lookup_for(&canonical_public_id(model_id), cloud))
}

/// The catalog model for a client-sent model id, accepting the Anthropic-native
/// spellings agent CLIs actually send alongside the catalog's public ids.
///
/// Claude Code's `/model` emits ids like `claude-sonnet-4-5-20250929` or
/// `claude-haiku-4-5`, Bedrock-aware clients may carry the full upstream id
/// (`us.anthropic.claude-haiku-4-5-20251001-v1:0`), and Vertex clients the
/// `@date` form (`claude-sonnet-4-5@20250929`). Exact public ids win; otherwise
/// the id is canonicalized — vendor/geo prefix, InvokeModel `-vN[:M]` suffix,
/// and either release-date suffix drop off, and a dashed minor version becomes
/// the catalog's dotted form (`claude-haiku-4-5` → `claude-haiku-4.5`).
///
/// A public id can appear once per cloud, and this returns the first catalog
/// entry — for a multi-cloud id that is the AWS one. Callers routing by a
/// binding must use `resolve_for` with the binding's cloud.
pub fn resolve(model_id: &str) -> Option<&'static CatalogModel> {
    lookup(model_id).or_else(|| lookup(&canonical_public_id(model_id)))
}

fn canonical_public_id(model_id: &str) -> String {
    let mut id = model_id;
    if let Some(pos) = id.rfind("anthropic.") {
        id = &id[pos + "anthropic.".len()..];
    }
    // Vertex spells the release date as an `@` suffix rather than a dash.
    id = id.split_once('@').map_or(id, |(base, _)| base);
    id = strip_invoke_version(id);
    id = strip_release_date(id);
    dot_minor_version(id)
}

/// Strip an InvokeModel version suffix: `-v1:0` or `-v1`.
fn strip_invoke_version(id: &str) -> &str {
    let base = id.split_once(':').map_or(id, |(base, _)| base);
    match base.rsplit_once("-v") {
        Some((stem, digits)) if !digits.is_empty() && digits.bytes().all(|b| b.is_ascii_digit()) => {
            stem
        }
        _ => base,
    }
}

/// Strip a release-date suffix: `-20251001`.
fn strip_release_date(id: &str) -> &str {
    match id.rsplit_once('-') {
        Some((stem, date))
            if date.len() == 8 && date.starts_with("20") && date.bytes().all(|b| b.is_ascii_digit()) =>
        {
            stem
        }
        _ => id,
    }
}

/// Rewrite a trailing dashed minor version to the catalog's dotted form:
/// `claude-haiku-4-5` → `claude-haiku-4.5`. Whole versions (`claude-sonnet-5`)
/// are already in catalog form and pass through.
fn dot_minor_version(id: &str) -> String {
    let Some((stem, minor)) = id.rsplit_once('-') else {
        return id.to_string();
    };
    let Some((prefix, major)) = stem.rsplit_once('-') else {
        return id.to_string();
    };
    let both_numeric = !major.is_empty()
        && !minor.is_empty()
        && major.bytes().all(|b| b.is_ascii_digit())
        && minor.bytes().all(|b| b.is_ascii_digit());
    if both_numeric {
        format!("{prefix}-{major}.{minor}")
    } else {
        id.to_string()
    }
}

/// The Azure predefined model deployments, as (deployment name, model name, version).
pub fn azure_deployments() -> Vec<(&'static str, &'static str, &'static str)> {
    AZURE_DEPLOYMENTS.to_vec()
}

#[cfg(test)]
mod tests {
    /// A public id may serve on more than one cloud (Claude does), but must appear at
    /// most once per cloud — a duplicate within a cloud would make `resolve_for`
    /// silently pick whichever entry comes first.
    #[test]
    fn public_ids_are_unique_per_cloud() {
        let mut seen = std::collections::HashSet::new();
        for model in super::CATALOG {
            assert!(
                seen.insert((model.cloud, model.public_id)),
                "public id '{}' appears more than once under {:?}",
                model.public_id,
                model.cloud
            );
        }
    }

    use super::*;

    #[test]
    fn resolve_accepts_anthropic_native_spellings() {
        // Claude Code /model forms: dashed minor version, with and without date.
        assert_eq!(resolve("claude-haiku-4-5").unwrap().public_id, "claude-haiku-4.5");
        assert_eq!(
            resolve("claude-sonnet-4-5-20250929").unwrap().public_id,
            "claude-sonnet-4.5"
        );
        // Full Bedrock upstream ids, with geo/vendor prefix and version suffix.
        assert_eq!(
            resolve("us.anthropic.claude-haiku-4-5-20251001-v1:0").unwrap().public_id,
            "claude-haiku-4.5"
        );
        assert_eq!(
            resolve("anthropic.claude-opus-4-6-v1").unwrap().public_id,
            "claude-opus-4.6"
        );
        // Whole versions are already catalog form.
        assert_eq!(resolve("claude-sonnet-5").unwrap().public_id, "claude-sonnet-5");
        // Exact public ids still win untouched.
        assert_eq!(resolve("claude-opus-4.8").unwrap().public_id, "claude-opus-4.8");
        assert_eq!(resolve("gpt-oss-20b").unwrap().public_id, "gpt-oss-20b");
        // Unknowns stay unknown — no fuzzy matching.
        assert!(resolve("claude-nonexistent-9-9").is_none());
        assert!(resolve("gpt-5").is_none());
    }

    #[test]
    fn aws_has_openai_and_anthropic_with_plain_ids() {
        let aws = models_for(Platform::Aws);
        assert!(!aws.is_empty());
        assert!(aws
            .iter()
            .any(|m| m.public_id == "gpt-oss-20b" && m.protocol == Protocol::OpenAi));
        assert!(
            aws.iter().any(|m| m.protocol == Protocol::Anthropic),
            "Claude must be included via the Anthropic protocol"
        );
        // The OpenAI endpoint rejects `us.*` cross-region profile ids.
        assert!(aws.iter().all(|m| !m.upstream_id.starts_with("us.")));
    }

    #[test]
    fn resolve_for_scopes_to_cloud() {
        // The same public id serves on more than one cloud with different upstream
        // ids, so resolution must scope to the binding's cloud.
        let aws = resolve_for("claude-opus-4.8", Platform::Aws).expect("aws claude");
        assert_eq!(aws.upstream_id, "anthropic.claude-opus-4-8");
        let gcp = resolve_for("claude-opus-4.8", Platform::Gcp).expect("gcp claude");
        assert_eq!(gcp.upstream_id, "claude-opus-4-8");
        assert_eq!(gcp.protocol, Protocol::Anthropic);
        // Canonicalization applies per cloud: Claude Code's dashed release-date
        // spelling resolves to the Vertex `@date` id.
        let dated = resolve_for("claude-haiku-4-5-20251001", Platform::Gcp).expect("dated id");
        assert_eq!(dated.upstream_id, "claude-haiku-4-5@20251001");
        // A Vertex-native `@date` spelling resolves too — it is the very id the
        // GCP catalog stores upstream.
        let vertex = resolve_for("claude-sonnet-4-5@20250929", Platform::Gcp).expect("vertex id");
        assert_eq!(vertex.upstream_id, "claude-sonnet-4-5@20250929");
        // A model serving on one cloud does not resolve on another.
        assert!(resolve_for("gemini-2.5-pro", Platform::Aws).is_none());
        assert!(resolve_for("gpt-4.1", Platform::Gcp).is_none());
    }

    #[test]
    fn lookup_round_trips() {
        let m = lookup("gpt-oss-20b").expect("known model");
        assert_eq!(m.cloud, Platform::Aws);
        assert_eq!(m.protocol, Protocol::OpenAi);
        assert_eq!(m.upstream_id, "openai.gpt-oss-20b-1:0");

        let c = lookup("claude-opus-4.8").expect("claude known");
        assert_eq!(c.protocol, Protocol::Anthropic);

        assert!(lookup("nonexistent-model").is_none());
    }

    #[test]
    fn azure_deployments_map_to_catalog() {
        assert!(!azure_deployments().is_empty());
        for (deployment, _, _) in azure_deployments() {
            assert!(
                models_for(Platform::Azure)
                    .iter()
                    .any(|m| m.upstream_id == deployment),
                "azure deployment {deployment} must map to a catalog model"
            );
        }
    }

    #[test]
    fn protocol_serializes_lowercase() {
        assert_eq!(serde_json::to_string(&Protocol::OpenAi).unwrap(), "\"openai\"");
        assert_eq!(serde_json::to_string(&Protocol::Anthropic).unwrap(), "\"anthropic\"");
        assert_eq!(
            serde_json::to_string(&Protocol::OpenAiResponses).unwrap(),
            "\"openairesponses\""
        );
    }

    #[test]
    fn every_model_has_provider_display_name_and_activation() {
        for m in CATALOG {
            assert_ne!(m.provider(), "unknown", "no provider mapping for '{}'", m.public_id);
            assert_ne!(
                m.display_name(),
                m.public_id,
                "no curated display_name for '{}'",
                m.public_id
            );
            // Only Claude needs a one-time step; everything else is out of the box.
            let is_claude = m.public_id.starts_with("claude");
            match m.activation() {
                Activation::OutOfBox => {
                    assert!(!is_claude, "'{}' (Claude) must require a one-time step", m.public_id)
                }
                Activation::RequiresOneTimeStep(summary) => {
                    assert!(is_claude, "'{}' must be out of the box", m.public_id);
                    assert!(!summary.is_empty(), "'{}' step summary is empty", m.public_id);
                }
            }
        }
    }

    /// The gateway forwards, it does not translate, so a client picks its wire format
    /// from the model id alone. Break this and an OpenAI body reaches the Anthropic
    /// upstream, or the reverse, for a bare 400 no caller can act on.
    #[test]
    fn only_claude_ids_speak_the_anthropic_protocol() {
        for m in CATALOG {
            assert_eq!(
                m.protocol == Protocol::Anthropic,
                m.public_id.starts_with("claude"),
                "'{}' is {:?} but its id says otherwise",
                m.public_id,
                m.protocol
            );
        }
    }
}