Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add Claude Fable 5 to Amazon Bedrock (#59016)

Edvard Høibyb497e2024aeb
diff --git a/crates/bedrock/src/models.rs b/crates/bedrock/src/models.rs
index a2f299a3c9e..9ebeffda7a8 100644
--- a/crates/bedrock/src/models.rs
+++ b/crates/bedrock/src/models.rs
@@ -107,6 +107,13 @@ pub enum Model {
alias = "claude-sonnet-4-6-thinking-latest"
)]
ClaudeSonnet4_6,
+ #[serde(
+ rename = "claude-fable-5",
+ alias = "claude-fable-5-latest",
+ alias = "claude-fable-5-thinking",
+ alias = "claude-fable-5-thinking-latest"
+ )]
+ ClaudeFable5,
// Meta Llama 4 models
#[serde(rename = "llama-4-scout-17b")]
@@ -219,7 +226,9 @@ impl Model {
}
pub fn from_id(id: &str) -> anyhow::Result<Self> {
- if id.starts_with("claude-opus-4-8") {
+ if id.starts_with("claude-fable-5") {
+ Ok(Self::ClaudeFable5)
+ } else if id.starts_with("claude-opus-4-8") {
Ok(Self::ClaudeOpus4_8)
} else if id.starts_with("claude-opus-4-7") {
Ok(Self::ClaudeOpus4_7)
@@ -253,6 +262,7 @@ impl Model {
Self::ClaudeOpus4_7 => "claude-opus-4-7",
Self::ClaudeOpus4_8 => "claude-opus-4-8",
Self::ClaudeSonnet4_6 => "claude-sonnet-4-6",
+ Self::ClaudeFable5 => "claude-fable-5",
Self::Llama4Scout17B => "llama-4-scout-17b",
Self::Llama4Maverick17B => "llama-4-maverick-17b",
Self::Gemma3_4B => "gemma-3-4b",
@@ -304,6 +314,7 @@ impl Model {
Self::ClaudeOpus4_7 => "anthropic.claude-opus-4-7",
Self::ClaudeOpus4_8 => "anthropic.claude-opus-4-8",
Self::ClaudeSonnet4_6 => "anthropic.claude-sonnet-4-6",
+ Self::ClaudeFable5 => "anthropic.claude-fable-5",
Self::Llama4Scout17B => "meta.llama4-scout-17b-instruct-v1:0",
Self::Llama4Maverick17B => "meta.llama4-maverick-17b-instruct-v1:0",
Self::Gemma3_4B => "google.gemma-3-4b-it",
@@ -355,6 +366,7 @@ impl Model {
Self::ClaudeOpus4_7 => "Claude Opus 4.7",
Self::ClaudeOpus4_8 => "Claude Opus 4.8",
Self::ClaudeSonnet4_6 => "Claude Sonnet 4.6",
+ Self::ClaudeFable5 => "Claude Fable 5",
Self::Llama4Scout17B => "Llama 4 Scout 17B",
Self::Llama4Maverick17B => "Llama 4 Maverick 17B",
Self::Gemma3_4B => "Gemma 3 4B",
@@ -406,7 +418,8 @@ impl Model {
| Self::ClaudeOpus4_6
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
- | Self::ClaudeSonnet4_6 => 1_000_000,
+ | Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5 => 1_000_000,
Self::ClaudeOpus4_1 => 200_000,
Self::Llama4Scout17B | Self::Llama4Maverick17B => 128_000,
Self::Gemma3_4B | Self::Gemma3_12B | Self::Gemma3_27B => 128_000,
@@ -440,7 +453,10 @@ impl Model {
| Self::ClaudeOpus4_5
| Self::ClaudeSonnet4_6 => 64_000,
Self::ClaudeOpus4_1 => 32_000,
- Self::ClaudeOpus4_6 | Self::ClaudeOpus4_7 | Self::ClaudeOpus4_8 => 128_000,
+ Self::ClaudeOpus4_6
+ | Self::ClaudeOpus4_7
+ | Self::ClaudeOpus4_8
+ | Self::ClaudeFable5 => 128_000,
Self::Llama4Scout17B
| Self::Llama4Maverick17B
| Self::Gemma3_4B
@@ -480,7 +496,8 @@ impl Model {
| Self::ClaudeOpus4_6
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
- | Self::ClaudeSonnet4_6 => 1.0,
+ | Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5 => 1.0,
Self::Custom {
default_temperature,
..
@@ -499,7 +516,8 @@ impl Model {
| Self::ClaudeOpus4_6
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
- | Self::ClaudeSonnet4_6 => true,
+ | Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5 => true,
Self::NovaLite | Self::NovaPro | Self::NovaPremier | Self::Nova2Lite => true,
Self::MistralLarge3 | Self::PixtralLarge | Self::MagistralSmall => true,
Self::Devstral2_123B | Self::Ministral14B => true,
@@ -531,7 +549,8 @@ impl Model {
| Self::ClaudeOpus4_6
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
- | Self::ClaudeSonnet4_6 => true,
+ | Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5 => true,
Self::NovaLite | Self::NovaPro => true,
Self::PixtralLarge => true,
Self::Qwen3VL235B => true,
@@ -550,7 +569,8 @@ impl Model {
| Self::ClaudeOpus4_6
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
- | Self::ClaudeSonnet4_6 => true,
+ | Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5 => true,
Self::Custom {
cache_configuration,
..
@@ -571,18 +591,23 @@ impl Model {
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
| Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5
)
}
pub fn supports_adaptive_thinking(&self) -> bool {
matches!(
self,
- Self::ClaudeOpus4_6 | Self::ClaudeOpus4_7 | Self::ClaudeOpus4_8 | Self::ClaudeSonnet4_6
+ Self::ClaudeOpus4_6
+ | Self::ClaudeOpus4_7
+ | Self::ClaudeOpus4_8
+ | Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5
)
}
pub fn supports_xhigh_adaptive_thinking(&self) -> bool {
- matches!(self, Self::ClaudeOpus4_8)
+ matches!(self, Self::ClaudeOpus4_8 | Self::ClaudeFable5)
}
pub fn thinking_mode(&self) -> BedrockModelMode {
@@ -616,6 +641,7 @@ impl Model {
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
| Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5
| Self::Nova2Lite
);
@@ -677,6 +703,7 @@ impl Model {
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
| Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5
| Self::Nova2Lite,
"global",
) => Ok(format!("{}.{}", region_group, model_id)),
@@ -695,6 +722,7 @@ impl Model {
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
| Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5
| Self::Llama4Scout17B
| Self::Llama4Maverick17B
| Self::NovaLite
@@ -718,6 +746,7 @@ impl Model {
| Self::ClaudeOpus4_7
| Self::ClaudeOpus4_8
| Self::ClaudeSonnet4_6
+ | Self::ClaudeFable5
| Self::NovaLite
| Self::NovaPro
| Self::Nova2Lite,
@@ -775,6 +804,10 @@ mod tests {
Model::ClaudeSonnet4.cross_region_inference_id("us-west-2", false)?,
"us.anthropic.claude-sonnet-4-20250514-v1:0"
);
+ assert_eq!(
+ Model::ClaudeFable5.cross_region_inference_id("us-east-1", false)?,
+ "us.anthropic.claude-fable-5"
+ );
assert_eq!(
Model::NovaPro.cross_region_inference_id("us-east-2", false)?,
"us.amazon.nova-pro-v1:0"
@@ -812,6 +845,10 @@ mod tests {
Model::ClaudeOpus4_8.cross_region_inference_id("eu-west-1", false)?,
"eu.anthropic.claude-opus-4-8"
);
+ assert_eq!(
+ Model::ClaudeFable5.cross_region_inference_id("eu-west-1", false)?,
+ "eu.anthropic.claude-fable-5"
+ );
Ok(())
}
@@ -918,6 +955,10 @@ mod tests {
Model::ClaudeOpus4_8.cross_region_inference_id("us-east-1", true)?,
"global.anthropic.claude-opus-4-8"
);
+ assert_eq!(
+ Model::ClaudeFable5.cross_region_inference_id("us-east-1", true)?,
+ "global.anthropic.claude-fable-5"
+ );
assert_eq!(
Model::Nova2Lite.cross_region_inference_id("us-east-1", true)?,
"global.amazon.nova-2-lite-v1:0"
@@ -989,6 +1030,7 @@ mod tests {
assert_eq!(Model::NovaLite.id(), "nova-lite");
assert_eq!(Model::DeepSeekR1.id(), "deepseek-r1");
assert_eq!(Model::Llama4Scout17B.id(), "llama-4-scout-17b");
+ assert_eq!(Model::ClaudeFable5.id(), "claude-fable-5");
assert_eq!(
Model::ClaudeSonnet4_5.request_id(),
@@ -1000,6 +1042,7 @@ mod tests {
Model::Llama4Scout17B.request_id(),
"meta.llama4-scout-17b-instruct-v1:0"
);
+ assert_eq!(Model::ClaudeFable5.request_id(), "anthropic.claude-fable-5");
// Thinking aliases deserialize to the same model
assert_eq!(Model::ClaudeSonnet4.id(), "claude-sonnet-4");
@@ -1007,6 +1050,10 @@ mod tests {
Model::from_id("claude-sonnet-4-thinking").unwrap().id(),
"claude-sonnet-4"
);
+ assert_eq!(
+ Model::from_id("claude-fable-5-thinking").unwrap().id(),
+ "claude-fable-5"
+ );
}
#[test]
@@ -1015,11 +1062,14 @@ mod tests {
assert!(Model::ClaudeSonnet4.supports_thinking());
assert!(Model::ClaudeSonnet4_5.supports_thinking());
assert!(Model::ClaudeOpus4_6.supports_thinking());
+ assert!(Model::ClaudeFable5.supports_thinking());
assert!(!Model::ClaudeSonnet4.supports_adaptive_thinking());
assert!(Model::ClaudeOpus4_6.supports_adaptive_thinking());
assert!(Model::ClaudeSonnet4_6.supports_adaptive_thinking());
+ assert!(Model::ClaudeFable5.supports_adaptive_thinking());
assert!(!Model::ClaudeOpus4_7.supports_xhigh_adaptive_thinking());
+ assert!(Model::ClaudeFable5.supports_xhigh_adaptive_thinking());
assert!(Model::ClaudeOpus4_8.supports_xhigh_adaptive_thinking());
assert_eq!(BedrockAdaptiveThinkingEffort::XHigh.as_str(), "xhigh");
@@ -1047,6 +1097,7 @@ mod tests {
fn test_max_token_count() {
assert_eq!(Model::ClaudeSonnet4_5.max_token_count(), 1_000_000);
assert_eq!(Model::ClaudeOpus4_6.max_token_count(), 1_000_000);
+ assert_eq!(Model::ClaudeFable5.max_token_count(), 1_000_000);
assert_eq!(Model::Llama4Scout17B.max_token_count(), 128_000);
assert_eq!(Model::NovaPremier.max_token_count(), 1_000_000);
}
@@ -1055,6 +1106,7 @@ mod tests {
fn test_max_output_tokens() {
assert_eq!(Model::ClaudeSonnet4_5.max_output_tokens(), 64_000);
assert_eq!(Model::ClaudeOpus4_6.max_output_tokens(), 128_000);
+ assert_eq!(Model::ClaudeFable5.max_output_tokens(), 128_000);
assert_eq!(Model::ClaudeOpus4_1.max_output_tokens(), 32_000);
assert_eq!(Model::Gemma3_4B.max_output_tokens(), 8_192);
}
@@ -1062,6 +1114,7 @@ mod tests {
#[test]
fn test_supports_tool_use() {
assert!(Model::ClaudeSonnet4_5.supports_tool_use());
+ assert!(Model::ClaudeFable5.supports_tool_use());
assert!(Model::NovaPro.supports_tool_use());
assert!(Model::MistralLarge3.supports_tool_use());
assert!(!Model::Gemma3_4B.supports_tool_use());
@@ -1076,6 +1129,7 @@ mod tests {
fn test_supports_caching() {
assert!(Model::ClaudeSonnet4_5.supports_caching());
assert!(Model::ClaudeOpus4_6.supports_caching());
+ assert!(Model::ClaudeFable5.supports_caching());
assert!(!Model::Llama4Scout17B.supports_caching());
assert!(!Model::NovaPro.supports_caching());
}
diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs
index ee673577c66..7d07261f641 100644
--- a/crates/language_models/src/provider/bedrock.rs
+++ b/crates/language_models/src/provider/bedrock.rs
@@ -670,6 +670,18 @@ impl LanguageModel for BedrockModel {
self.model.supports_thinking()
}
+ fn refusal_fallback_model_id(&self) -> Option<&'static str> {
+ if self
+ .model
+ .id()
+ .starts_with(anthropic::FABLE_MODEL_ID_PREFIX)
+ {
+ Some(anthropic::FABLE_FALLBACK_MODEL_ID)
+ } else {
+ None
+ }
+ }
+
fn supported_effort_levels(&self) -> Vec<language_model::LanguageModelEffortLevel> {
if self.model.supports_adaptive_thinking() {
vec![