fix(bedrock): strip [1m]/[200k] context window suffixes before cost lookup

This commit is contained in:
Ishaan Jaffer 2026-04-01 12:16:54 -07:00
parent e4442a4d98
commit 440c3387df

View file

@ -432,12 +432,16 @@ def strip_bedrock_routing_prefix(model: str) -> str:
def strip_bedrock_throughput_suffix(model: str) -> str:
"""Strip throughput tier suffixes from Bedrock model names."""
"""Strip throughput tier suffixes and context window suffixes from Bedrock model names."""
import re
# Pattern matches model:version:throughput where throughput is like 51k, 18k, etc.
# Keep the model:version part, strip the :throughput suffix
return re.sub(r"(:\d+):\d+k$", r"\1", model)
model = re.sub(r"(:\d+):\d+k$", r"\1", model)
# Strip context window suffixes like [1m], [200k], etc.
# e.g. "us.anthropic.claude-opus-4-6-v1[1m]" -> "us.anthropic.claude-opus-4-6-v1"
model = re.sub(r"\[\w+\]$", "", model)
return model
def get_bedrock_base_model(model: str) -> str:
@ -1062,9 +1066,11 @@ class CommonBatchFilesUtils:
return (
dict(prepped.headers),
request_data.encode("utf-8")
if isinstance(request_data, str)
else request_data,
(
request_data.encode("utf-8")
if isinstance(request_data, str)
else request_data
),
)
def generate_unique_job_name(self, model: str, prefix: str = "litellm") -> str: