AWS Bedrock Beyond the Base Models, Considering Custom Models.

Michael Wahl
3 min readJan 22, 2024

I have been experimenting with AWS Bedrock for a few weeks! With more of a focus on text or content generation, and summarization, and much less on Chat or Q&A and illustration generation.

There are already many articles, blogs, and videos that cover the basics of the bedrock services, and making API/Python boto3 calls, so I won’t cover those areas here.

I want to share some code examples of using Python boto3 to make calls using the base foundational models in AWS bedrock, but also using custom models that were trained on the base foundation models.

There are a couple of parameters in the code below that can be modified for your specific use case or just leave them as is and experiment with them and observe the changes in the outputs. You can change the inputText (prompt) to whatever you want. Save this code and run it as Python3 FileName.py

import boto3
import json
bedrock = boto3.client(service_name= 'bedrock-runtime', region_name= 'us-east-1')
modelId = '**amazon.titan-text-lite-v1**'
accept = 'application/json'
contentType = 'application/json'
body = json.dumps({
"inputText": "Write a blog about EVs and the environment.",
"textGenerationConfig": {
"maxTokenCount": 1024,
"temperature":0.4,
"topP":1
}
})

--

--

Michael Wahl

Husband | Dad | VP of IT | MBA | Author | AI | #AWSCommunityBuilder | Opinions expressed here are my own | https://michaelwahl.carrd.co