Cloud

AWS Bedrock: Getting Started with Generative AI on AWS

Learn what AWS Bedrock is, how pricing works, which foundation models are available, and how to build your first generative AI application. Complete guide with code examples.

By InventiveHQ Team

Amazon Bedrock is AWS's fully managed, serverless service that gives you a single API to call foundation models from Anthropic, Meta, Mistral, Cohere, Amazon, and Stability AI β€” with access governed by IAM and usage billed through your AWS account. Cross-Region inference profiles can process requests outside the selected Region. You do not manage GPUs; check current model access and pricing, then call bedrock-runtime with a model available to your account. The trade versus calling Anthropic or OpenAI directly is a little more setup in exchange for VPC isolation, native IAM, and AWS compliance coverage.

That is the summary an AI Overview can give you. What it can't show you is the number that actually decides your architecture: what will this cost at your real traffic? So this guide leads with a live AWS Bedrock pricing calculator you can drive with your own token counts, an animated diagram of how a Knowledge Base actually answers a question, and opinionated tables on when Bedrock beats a direct API β€” plus working Boto3 code for your first call.

Model the Cost Before You Write Code

Pricing decides which model you can afford to put in production, so start here. Enter your input and output token counts per request and your request volume; the calculator estimates monthly spend across Claude, Llama, and Titan so you can compare a Haiku-first design against Sonnet before committing.

Interactive toolAws Bedrock Pricing CalculatorRuns in your browser β€” nothing is uploaded.

The rest of this guide explains what you're paying for and how to build on it.

What Is AWS Bedrock?

Amazon Bedrock is a serverless service that provides:

  • Foundation model access - Claude, Llama, Mistral, and more via API
  • Fine-tuning capabilities - Customize models with your data
  • RAG support - Connect models to your knowledge bases
  • Agents - Build autonomous AI workflows
  • Guardrails - Control model outputs for safety

Think of Bedrock as a "model marketplace with infrastructure"β€”you choose which AI models to use, AWS handles scaling, security, and availability.

Why Use Bedrock Instead of Direct APIs?

You could use Anthropic's API directly, so why go through AWS?

FactorDirect APIAWS Bedrock
BillingSeparate vendorConsolidated AWS billing
Data residencyVaries by provider and configurationDepends on model and inference profile; review destination Regions
VPC integrationRequires configurationPrivateLink available
IAM integrationAPI keys onlyNative IAM policies
Multiple modelsMultiple accounts/APIsSingle API, many models
ComplianceDepends on service and configurationDepends on service eligibility and your configuration
Model switchingDepends on providerConverse can simplify supported model changes

Key benefit: If you're already on AWS and need enterprise controls (VPC, IAM, compliance), Bedrock simplifies integration significantly.

Available Foundation Models

Bedrock offers models from multiple providers. Availability and model versions change by Region; check the console before selecting one. The examples below illustrate provider categories rather than a current availability list:

Text Generation Models

ProviderModel familyBest For
AnthropicClaudeReasoning and coding
MetaLlamaOpen-weight alternatives
MistralMistralMultilingual and coding tasks
AmazonNova and TitanGeneral text tasks
CohereCommandRAG applications

Image Generation Models

ProviderModelUse Case
Stability AIImage modelsImage generation
AmazonTitan Image GeneratorText-to-image, editing

Embedding Models

ProviderModelDimensions
AmazonTitan Embeddings V21024
CohereEmbed1024

Bedrock Pricing Explained

Bedrock uses token-based pricingβ€”you pay per input and output token processed. Pricing varies significantly by model.

Text Model Pricing (per 1,000 tokens)

Input and output token rates vary by model, Region, and inference option. Check current AWS pricing for the model you select.

Example Cost Calculation

Multiply your expected input and output tokens by the corresponding current rates, then by request volume. Include any additional charges for features your application uses.

Provisioned Throughput

For predictable, high-volume workloads, compare available committed-capacity options with on-demand pricing. Availability, commitment terms, and pricing depend on the model and current AWS offering.

Getting Started: Your First Bedrock Call

Prerequisites

  1. AWS account with Bedrock available in your chosen Region
  2. Check the access steps for your selected model or inference profile
  3. IAM permissions for bedrock:InvokeModel

Python Example with Boto3

Set BEDROCK_MODEL_ID to an available model or inference profile ID in your account before running these examples.

import boto3
import json
import os

# Create Bedrock runtime client
bedrock = boto3.client(
    service_name='bedrock-runtime',
    region_name='us-east-1'
)

# Prepare the request for Claude
body = json.dumps({
    "anthropic_version": "bedrock-2023-05-31",
    "max_tokens": 1024,
    "messages": [
        {
            "role": "user",
            "content": "Explain what AWS Bedrock is in 2 sentences."
        }
    ]
})

# Invoke the model
response = bedrock.invoke_model(
    modelId=os.environ["BEDROCK_MODEL_ID"],
    contentType="application/json",
    accept="application/json",
    body=body
)

# Parse response
response_body = json.loads(response['body'].read())
print(response_body['content'][0]['text'])

The Converse API provides a unified interface across supported models:

import boto3
import os

bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')

response = bedrock.converse(
    modelId=os.environ["BEDROCK_MODEL_ID"],
    messages=[
        {
            "role": "user",
            "content": [{"text": "What is AWS Bedrock?"}]
        }
    ],
    inferenceConfig={
        "maxTokens": 1024,
        "temperature": 0.7
    }
)

print(response['output']['message']['content'][0]['text'])

Benefit: Converse shares a message format across supported models, but switching may still require changes to parameters, inference profiles, or response handling.

Bedrock Knowledge Bases (RAG)

Knowledge Bases let you connect foundation models to your own data using Retrieval-Augmented Generation (RAG).

How It Works

A Knowledge Base turns a plain question into a grounded answer by retrieving your own documents before the model responds. The animated flow below traces a single query through the four stages Bedrock runs for you.

How a Bedrock Knowledge Base answers a question with RAG A user question is embedded, matched against a vector store of your document chunks, passed with the retrieved chunks to a foundation model, and returned as an answer with citations. User question "What is our refund SLA?" 1 Β· Embed question β†’ vector 2 Β· Retrieve top-k chunks Vector store your S3 docs, chunked + embedded 3 Β· Generate chunks + question β†’ foundation model Grounded answer with citations
Advertisement

Supported Data Sources

  • Amazon S3 (PDF, TXT, MD, HTML, DOC, CSV)
  • Web crawlers
  • Confluence
  • Salesforce
  • SharePoint

Creating a Knowledge Base

This example illustrates the required configuration shape. The sample ARNs and index names must be replaced with real resources before it can run.

import boto3

bedrock_agent = boto3.client('bedrock-agent', region_name='us-east-1')

# Create knowledge base
response = bedrock_agent.create_knowledge_base(
    name='company-docs-kb',
    roleArn='arn:aws:iam::123456789:role/BedrockKBRole',
    knowledgeBaseConfiguration={
        'type': 'VECTOR',
        'vectorKnowledgeBaseConfiguration': {
            'embeddingModelArn': 'arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-embed-text-v2:0'
        }
    },
    storageConfiguration={
        'type': 'OPENSEARCH_SERVERLESS',
        'opensearchServerlessConfiguration': {
            'collectionArn': 'arn:aws:aoss:us-east-1:123456789:collection/abc123',
            'vectorIndexName': 'bedrock-kb-index',
            'fieldMapping': {
                'vectorField': 'embedding',
                'textField': 'text',
                'metadataField': 'metadata'
            }
        }
    }
)

Bedrock Agents

Agents enable foundation models to take actions by connecting to external tools and APIs.

Example: Customer Service Agent

An agent can:

  1. Look up customer orders in your database
  2. Check inventory status via API
  3. Create support tickets
  4. Send confirmation emails

Agent Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        User Input                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Bedrock Agent                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              Foundation Model (Claude)               β”‚    β”‚
β”‚  β”‚         Reasons about what actions to take           β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                              β”‚                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚  β”‚ Action Group β”‚  β”‚ Action Group β”‚  β”‚ Knowledge    β”‚       β”‚
β”‚  β”‚ (Lambda)     β”‚  β”‚ (API Schema) β”‚  β”‚ Base         β”‚       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Final Response                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Guardrails: Control Model Outputs

Guardrails let you define policies to filter harmful content and protect sensitive data.

Guardrail Capabilities

FeatureDescription
Content filtersBlock hate, violence, sexual content, etc.
Denied topicsPrevent discussion of specific topics
Word filtersBlock specific words or phrases
PII detectionMask or block personal information
Contextual groundingReduce hallucinations with source verification

Creating a Guardrail

import boto3

bedrock = boto3.client('bedrock', region_name='us-east-1')

response = bedrock.create_guardrail(
    name='customer-support-guardrail',
    description='Guardrail for customer support chatbot',
    contentPolicyConfig={
        'filtersConfig': [
            {'type': 'HATE', 'inputStrength': 'HIGH', 'outputStrength': 'HIGH'},
            {'type': 'VIOLENCE', 'inputStrength': 'HIGH', 'outputStrength': 'HIGH'},
        ]
    },
    sensitiveInformationPolicyConfig={
        'piiEntitiesConfig': [
            {'type': 'CREDIT_DEBIT_CARD_NUMBER', 'action': 'BLOCK'},
            {'type': 'US_SOCIAL_SECURITY_NUMBER', 'action': 'BLOCK'},
        ]
    },
    blockedInputMessaging='I cannot process this request.',
    blockedOutputsMessaging='I cannot provide this information.'
)

Model Fine-Tuning

Bedrock supports fine-tuning select models with your own data to improve performance on specific tasks.

Supported Models for Fine-Tuning

Fine-tuning support varies by model and Region. Check the current Bedrock model catalog before choosing a base model.

Fine-Tuning Process

  1. Prepare training data - JSONL format with prompt/completion pairs
  2. Upload to S3 - Training data in your bucket
  3. Create fine-tuning job - Specify base model and hyperparameters
  4. Deploy custom model - Check the available hosting option for your model

Training Data Format

{"prompt": "Summarize this support ticket:", "completion": "Customer reports login issue..."}
{"prompt": "Summarize this support ticket:", "completion": "User cannot reset password..."}

Best Practices

1. Start with Smaller Models

Use a lower-cost model available in your Region for development and testing. Move to a larger model only when needed for production quality.

2. Implement Caching

Cache common responses to reduce costs:

import hashlib

def get_cached_or_call(prompt, cache):
    cache_key = hashlib.md5(prompt.encode()).hexdigest()
    if cache_key in cache:
        return cache[cache_key]

    response = bedrock.converse(...)
    cache[cache_key] = response
    return response

3. Use Streaming for Long Responses

import os

response = bedrock.converse_stream(
    modelId=os.environ["BEDROCK_MODEL_ID"],
    messages=[{"role": "user", "content": [{"text": "Write a long story"}]}]
)

for event in response['stream']:
    if 'contentBlockDelta' in event:
        print(event['contentBlockDelta']['delta']['text'], end='')

4. Monitor Costs

Set up CloudWatch alarms for Bedrock metrics:

  • InvocationCount - Track usage volume
  • InvocationLatency - Monitor response times
  • TokenCount - Watch token consumption

5. Use VPC Endpoints for Security

aws ec2 create-vpc-endpoint \
  --vpc-id vpc-123456 \
  --service-name com.amazonaws.us-east-1.bedrock-runtime \
  --vpc-endpoint-type Interface

Bedrock vs OpenAI vs Direct Anthropic

FactorAWS BedrockOpenAI APIAnthropic Direct
Model varietyMultiple providersOpenAI onlyClaude only
AWS integrationNativeManualManual
Enterprise complianceDepends on service and configurationDepends on service and configurationDepends on service and configuration
PricingCheck current model and RegionCheck current ratesCheck current rates
Fine-tuningModel dependentModel dependentModel dependent
Setup complexityAWS knowledge neededSimple API keySimple API key
Which should I use / whenYou need AWS integration and its controlsYour application uses OpenAI modelsYour application uses Anthropic models directly

Getting Started Checklist

  1. Enable Bedrock in your AWS account
  2. Request model access for the models you need
  3. Set up IAM permissions for your users/services
  4. Start with Converse API for model-agnostic code
  5. Test with Haiku/Titan before using expensive models
  6. Add Guardrails for production deployments
  7. Monitor costs with CloudWatch and billing alerts

AWS Bedrock lowers the barrier to building production AI applications while providing enterprise-grade security and compliance. Start experimenting with the playground in the AWS console, then move to the API for production workloads.

Frequently Asked Questions

What is AWS Bedrock and how is it different from using the Anthropic or OpenAI API directly?

AWS Bedrock is a fully managed, serverless service that gives you one API to call foundation models from Anthropic, Meta, Mistral, Cohere, Amazon, and Stability AI. The difference from calling a provider directly is operational, not the model itself: with Bedrock you can use AWS IAM and regional controls, but cross-Region inference profiles can route prompts and completions to other Regions, access is governed by IAM policies instead of a shared API key, traffic can stay on your VPC via PrivateLink, and usage rolls into your consolidated AWS bill under existing compliance agreements (HIPAA, SOC 2, etc.). You trade a little setup complexity for enterprise controls.

How much does AWS Bedrock cost?

On-demand pricing varies by model, Region, and inference option. Check the current AWS price for the model and routing mode you intend to use, then use the embedded calculator to estimate your workload.

Do I need to request access before I can use a Bedrock model?

Access steps vary by model and can change. Check the current model-access instructions in the Bedrock console and make sure your IAM principal has permission to invoke the model or inference profile you choose.

Should I use the InvokeModel API or the Converse API?

Use the Converse API for almost everything new. InvokeModel requires you to hand-build each provider's request/response JSON (Anthropic uses anthropic_version and messages; Titan uses a different shape), so switching models means rewriting code. Converse gives one unified request format across all Bedrock models β€” you the same message format can serve many models, though model support, parameters, and response behavior can differ. Reach for InvokeModel only when you need a provider-specific parameter that Converse does not yet surface.

What are Bedrock Knowledge Bases and when should I use them?

Knowledge Bases are Bedrock's managed Retrieval-Augmented Generation (RAG) pipeline. You point them at data (S3, web crawl, Confluence, Salesforce, SharePoint), Bedrock chunks and embeds it into a vector store such as OpenSearch Serverless, and at query time it retrieves the relevant chunks and passes them to the model with the question. Use them when answers must be grounded in your own documents with citations rather than the model's training data β€” for example an internal support or policy assistant.

Does my data get used to train the foundation models on Bedrock?

No. AWS states that prompts and completions sent to Bedrock are not used to train the base foundation models and are not shared with model providers. Cross-Region inference profiles may process requests in other Regions, so check the profile’s destination Regions for residency requirements. Fine-tuning creates a private copy of the model trained only on your data and accessible only to your account. This is the main reason regulated teams choose Bedrock over consumer-facing APIs.

What are Bedrock Guardrails and do they cost extra?

Guardrails are policies you attach to model calls to filter harmful content, block denied topics, redact or block PII, and reduce hallucinations via contextual grounding. They are evaluated on both the input and the output and are billed separately from token usage, based on the amount of text and the number of policy checks. For any production, customer-facing deployment they are strongly recommended.

Which region should I run Bedrock in?

Choose the region closest to your users that also offers the specific model you need β€” model availability varies by region, and us-east-1 and us-west-2 typically have the widest selection first. Keep your Bedrock calls, Knowledge Base vector store, and application in the same region to minimize latency and avoid cross-region data transfer. Cross-Region inference profiles can route requests to other Regions; global profiles may include destinations worldwide. Review the destination Regions of the selected profile.