MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / prefix_model_id

Method prefix_model_id

crates/opencode-provider/src/bootstrap.rs:460–542  ·  view source on GitHub ↗
(model_id: &str, region: &str)

Source from the content-addressed store, hash-verified

458 // TODO: Wire for Bedrock cross-region routing
459 #[allow(dead_code)]
460 pub fn prefix_model_id(model_id: &str, region: &str) -> String {
461 // Skip if model already has a cross-region inference profile prefix
462 let cross_region_prefixes = ["global.", "us.", "eu.", "jp.", "apac.", "au."];
463 if cross_region_prefixes
464 .iter()
465 .any(|p| model_id.starts_with(p))
466 {
467 return model_id.to_string();
468 }
469
470 let region_prefix = region.split('-').next().unwrap_or("");
471 let mut result_id = model_id.to_string();
472
473 match region_prefix {
474 "us" => {
475 let model_requires_prefix = [
476 "nova-micro",
477 "nova-lite",
478 "nova-pro",
479 "nova-premier",
480 "nova-2",
481 "claude",
482 "deepseek",
483 ]
484 .iter()
485 .any(|m| model_id.contains(m));
486 let is_gov_cloud = region.starts_with("us-gov");
487 if model_requires_prefix && !is_gov_cloud {
488 result_id = format!("{}.{}", region_prefix, model_id);
489 }
490 }
491 "eu" => {
492 let region_requires_prefix = [
493 "eu-west-1",
494 "eu-west-2",
495 "eu-west-3",
496 "eu-north-1",
497 "eu-central-1",
498 "eu-south-1",
499 "eu-south-2",
500 ]
501 .iter()
502 .any(|r| region.contains(r));
503 let model_requires_prefix =
504 ["claude", "nova-lite", "nova-micro", "llama3", "pixtral"]
505 .iter()
506 .any(|m| model_id.contains(m));
507 if region_requires_prefix && model_requires_prefix {
508 result_id = format!("{}.{}", region_prefix, model_id);
509 }
510 }
511 "ap" => {
512 let is_australia_region = region == "ap-southeast-2" || region == "ap-southeast-4";
513 let is_tokyo_region = region == "ap-northeast-1";
514
515 if is_australia_region
516 && ["anthropic.claude-sonnet-4-5", "anthropic.claude-haiku"]
517 .iter()

Callers

nothing calls this directly

Calls 1

containsMethod · 0.80

Tested by

no test coverage detected