Skip to content

How to filter listed foundation models by model access

0

I have granted access to a few of the models on Bedrock and I want to see those models on my site. I am listing foundation models using aws sdk command ListFoundationModelsCommand and discovered that I am unable to filter by Model Access. The returned list also does not include model access status either so I am unsure as to how to proceed.

example code

const command = new ListFoundationModelsCommand({
    byOutputModality: 'TEXT',
});

const response = await bedrockClient.send(command);
1 Answer
0

When using the ListFoundationModelsCommand in the AWS SDK, you're right that there isn't a direct filter parameter for model access status. The command returns all foundation models available in the region, regardless of whether you've been granted access to them or not.

To determine which models you have access to, you have a few options:

  1. After retrieving the list of foundation models, you can make a separate call to check the access status for each model. However, this approach would require multiple API calls.

  2. A more practical approach is to handle this programmatically by maintaining a list of models you've granted access to in your application, or by attempting to use the models and handling any access-related errors.

  3. You can also use the AWS CLI to get a list of models you have access to and use that information in your application:

aws bedrock list-foundation-models --query "modelSummaries"[]."modelArn"

It's worth noting that some models like Amazon Titan, Mistral AI models, and Meta Llama 3 Instruct cannot be disabled once enabled, so you'll always have access to these once granted.

If you need to restrict access to specific models for certain users, you can implement identity-based policies that deny access to running inference on specific models, even if model access has been granted at the account level.
Sources
Restricting Access to Amazon Bedrock Models | AWS re:Post
Bedrock Model access modifications | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.