feat(bedrock): add list_inference_profiles() to BedrockInferenceAdapter for cross-region model autodiscovery
Describe the new functionality needed
Update BedrockInferenceAdapter.list_provider_model_ids() in ogx/providers/remote/inference/bedrock/bedrock.py to call Bedrock's list_inference_profiles() API (typeEquals="SYSTEM_DEFINED") in addition to list_foundation_models(byInferenceType="ON_DEMAND").
Why is this needed? What if we don't build it?
Currently, BedrockInferenceAdapter.list_provider_model_ids() only queries list_foundation_models(byInferenceType="ON_DEMAND").
Modern Llama 3 models on AWS Bedrock (such as Llama 3.1 8B, Llama 3.3 70B, and Claude 3.5) require cross-region inference profile IDs (such as us.meta.llama3-1-8b-instruct-v1:0). When invoking Bedrock's OpenAI-compatible or Converse endpoints with a bare foundation model ID (meta.llama3-1-8b-instruct-v1:0), Bedrock returns 404: The model doesn't exist or doesn't support this API.
Cross-region inference profile IDs are only returned by Bedrock's list_inference_profiles() control-plane API. Without querying list_inference_profiles(), Bedrock autodiscovery returns 0 inference profiles at server startup, causing model lookup and chat completion requests for cross-region models to fail with 404.
Other thoughts
Proposed implementation in BedrockInferenceAdapter.list_provider_model_ids():
async def list_provider_model_ids(self) -> Iterable[str]:
if self._should_use_sigv4():
if self._bedrock_client is None:
return []
model_ids = []
try:
response = await asyncio.to_thread(
self._bedrock_client.list_foundation_models,
byInferenceType="ON_DEMAND",
)
model_ids.extend([
m["modelId"] for m in response.get("modelSummaries", [])
if m.get("modelLifecycleStatus") == "ACTIVE"
])
except Exception:
logger.warning("Failed to list Bedrock foundation models", exc_info=True)
try:
ip_response = await asyncio.to_thread(
self._bedrock_client.list_inference_profiles,
typeEquals="SYSTEM_DEFINED",
)
model_ids.extend([
ip["inferenceProfileId"] for ip in ip_response.get("inferenceProfileSummaries", [])
if ip.get("status") == "ACTIVE"
])
except Exception:
logger.warning("Failed to list Bedrock inference profiles", exc_info=True)
return model_idsSource: ogx-ai/ogx