Amazon Bedrock — an Enterprise Generative AI Service

Meenakshisundaram Thandavarayan
4 min readOct 25, 2023

Amazon Bedrock

Amazon Bedrock is a fully managed generative AI service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Stability AI, and Amazon with a single API, along with a broad set of capabilities you need to build generative AI applications, simplifying development while maintaining privacy and security.

All Amazon Bedrock endpoints in all regions only support HTTPS. Customers can leverage VPC Interface Endpoints to establish a private connection between your VPC and Bedrock. Interface endpoints are powered by AWS PrivateLink, this enables you to privately access Bedrock APIs without an internet gateway

Amazon Bedrock Features

  • Generative AI Capabilities — Amazon Bedrock provides all foundational platform capabilities to consume, fine tune, deploy and operationalize Gen AI — Models, Knowledge bases, Agents, Orchestration and customizations
  • Secure by design — All Models are hosted in an AWS environment. Data is always within the Customer Environment. No data leaves the AWS environment, data is not stored, used for any retraining purposes
  • Serverless — API driven, No provisioning of infrastructure, scaling. Undifferentiated heavy lifting of hosting Models, Knowledge bases, orchestration are done by Amazon Bedrock
  • No Vendor Lock In — Bedrock provides choice for all capabilities. 1st party, partner models, open-source models, supports Vector Databases — Pinecone, Redis, OpenSearch, extends LangChain…
  • Customizable — Bedrock enables fine tuning models to adapt to your data / domain
  • Extensible — integrates with the AWS ecosystem for foundational and value-added capabilities — Storage, Compute, AI Services…. to address pace of Gen AI innovation
  • Gen AI for All: Built for all personas to infuse Gen AI in their applications — No Code, Low Code and High Code users
  • Observability: Provides transparency and control, integration with CloudWatch, CloudTrail, Cost Explorer….

Amazon Bedrock is integrated with the AWS services landscape. It leverages integration with S3 for fine tuning custom Models. Bedrock Agents leverages AWS Lambda functions to extends the capability to other AWS Services. Thus enabling customers to address diverse use case requirements. For example

  • Integration with AI Services like Amazon Textract, Amazon Rekognition, Amazon Transcribe, Amazon Translate enables handling of multi modality, multi lingual and complex document processing use cases
  • Integration with Amazon Comprehend enables you to add guardrail in prompt
  • Integration with AppFlow, App Sync enables data ingestion from multitude of systems of records
  • Integration with Data services from RDS Aurora to Redshift addresses text to sql or advanced reporting use cases.
  • Integration with orchestration tools like Step Functions extends chaining multiple tasks

Amazon Bedrock Set up

Enabling Amazon Bedrock is very similar to any other AWS service. Security Accelerators are provided to review enterprise security needs and once approved to use, it is as simple as enabling the SCP policies to have the service available. Enabling of the Bedrock Service does NOT have COST attached to it. Costs are incurred on as Pay per use basis based on the invocation payload and response (token counts)

Alternatively, you can choose to set up a single Gen AI sandbox environment for their POC purposes if they chose to do so. In this case, an AWS account with Bedrock access is set up. The endpoints are made available to LOBs using Lambda / API Gateway. All of the services are Serverless and there is NO Cost incurred for the Sandbox environment.

Pricing Models

Bedrock offers 2 pricing for using LLMs through Bedrock. There is a “pay as you go” on-demand price with no commitment, that works like other AWS services. This will be your best choice for PoC’s and other short-term usage requirements.

Provisioned Throughput is another pricing model for throughput-sensitive workload where you need the most predictable performance. This capability will provide more control over the throughput of Bedrock models, offering guaranteed throughput measured in tokens per minute or requests per minute. This will require at least a one month commitment, and will work similarly to AWS Reserved Instances. This will be your best choice for full production.

Get started with Amazon Bedrock

Infusing generative ai capabilities using Amazon Bedrock on to your application can be done in 3 lines of code

  1. Get the pointer to the Bedrock Service
import boto3
import json

boto3_bedrock = boto3.client("bedrock-runtime")

2. Design the prompt and set up inference configuration parameters

prompt_data = """
Human: Write me a blog about making strong business decisions as a leader
Assistant:
"""

body = json.dumps({"prompt": prompt_data, "max_tokens":400, "temperature":0.0})
modelId = "anthropic.claude-instant-v1"
accept = "application/json"
contentType = "application/json"

To invoke a different model other than Claude Instant, just change the name of the model in the model id parameter.

3. Invoke the Amazon Bedrock Model

response = bedrock_runtime.invoke_model(
body=body, modelId=modelId, accept=accept, contentType=contentType
)
response_body = json.loads(response.get("body").read())

print(response_body.get("completion"))

Other use case implementations from RAG patterns, text to sql and code generation are available here — https://github.com/aws-samples/amazon-bedrock-workshop/

--

--