To retrieve available models or versions via the Bedrock API, use the ListFoundationModels
API operation. This method returns metadata about all foundation models accessible through Bedrock, including their identifiers, providers (e.g., Anthropic, AI21 Labs), and supported features. You’ll need to authenticate your API requests using AWS credentials and target the Bedrock service endpoint for your region.
First, initialize the Bedrock client using the AWS SDK for your programming language (e.g., Python’s boto3
). For example, in Python:
import boto3
client = boto3.client('bedrock', region_name='us-west-2')
response = client.list_foundation_models()
The response includes a modelSummaries
array with entries like:
{
"modelId": "anthropic.claude-v2",
"modelName": "Claude",
"providerName": "Anthropic",
"inputModalities": ["TEXT"],
"outputModalities": ["TEXT"],
"customizationsSupported": ["FINE_TUNING"]
}
Each modelId
often encodes version information (e.g., claude-v2
). To filter results, use optional parameters like byProvider
or byOutputModality
in the API call.
If you need detailed version information beyond what’s in modelId
, use the GetFoundationModel
API with a specific modelId
. This returns additional metadata, including lifecycle status and any version-specific constraints. Note that model availability depends on your AWS region and account permissions, so ensure your IAM roles grant bedrock:ListFoundationModels
access. For CLI users, the equivalent command is aws bedrock list-foundation-models
.