Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions crates/braintrust-llm-router/src/providers/bedrock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ pub(crate) fn requires_bedrock_request_preparation(format: ProviderFormat) -> bo
)
}

// xAI/Grok on Bedrock is served only on the `bedrock-mantle` host, not
// `bedrock-runtime`.
// Some Bedrock models are served only on the `bedrock-mantle` host, not
// `bedrock-runtime`: xAI/Grok (`xai.`) and Google Gemma 4 (`google.gemma-4`).
// Gemma 3 is excluded on purpose — it is served on `bedrock-runtime` and uses a
// different mantle OpenAI path (`/v1` rather than `/openai/v1`).
fn is_bedrock_mantle_only_model(model: &str) -> bool {
model.starts_with("xai.")
model.starts_with("xai.") || model.starts_with("google.gemma-4")
}

/// Prepare a Bedrock-targeted request by inlining client-provided remote image URLs.
Expand Down Expand Up @@ -702,6 +704,36 @@ mod tests {
);
}

#[test]
fn chat_completions_url_routes_gemma_models_to_mantle() {
let provider = provider();
for model in [
"google.gemma-4-e2b",
"google.gemma-4-31b",
"google.gemma-4-26b-a4b",
] {
let url = provider.chat_completions_url(model).unwrap();
assert_eq!(
url.as_str(),
"https://bedrock-mantle.us-east-1.api.aws/openai/v1/chat/completions",
"model {model} should route to the bedrock-mantle host"
);
}
}

#[test]
fn chat_completions_url_keeps_gemma_3_on_bedrock_runtime() {
let provider = provider();
let url = provider
.chat_completions_url("google.gemma-3-27b-it")
.unwrap();
assert_eq!(
url.as_str(),
"https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions",
"Gemma 3 is served on bedrock-runtime, not the mantle host"
);
}

#[test]
fn chat_completions_url_preserves_custom_endpoint_path() {
let config = BedrockConfig {
Expand Down
Loading