What Is Amazon Bedrock? Generative AI APIs on AWS Explained
Bedrock lets your app talk to foundation models (Claude, Llama, Titan and others) over AWS APIs. You do not train a giant GPU farm first. Perfect for chat, summarise and classify — with strict token cost discipline.
In this chapter
- What Bedrock is
- Model access and regions
- Pricing mental model (tokens)
- Guardrails and IAM
- Cost warnings for student labs
1. Everyday example
A Swiggy support bot must turn a long complaint into a short category + reply draft. Building that model from scratch is years of work. Calling a foundation model with a good prompt can be a weekend.
Amazon Bedrock is a fully managed service to use foundation models via API (and tools like Knowledge Bases / Agents). Providers include Amazon and third parties, depending on region and account enablement.
2. Model access
Suppose a college help desk wants a two-sentence summary of a student’s ticket. The app sends a prompt, which is the instructions and example text supplied to the model. Bedrock exposes supported models through an API so the app can make that request. In a Converse request, identify the model, the list of messages and the role of each message. When a response arrives, read the returned message, the reason it stopped and the usage fields. These answer different questions: what it said, whether it finished normally, and how much input and output it processed.
Not every model is on in every account/region by default.
- Open the Bedrock Model catalog, choose the model and review its access requirements. Many models are enabled with the required permissions; some have provider or Marketplace prerequisites.
- Check the model is available in your region (Mumbai support grows over time — verify live).
- Call with AWS SDK (
bedrock-runtime) using an IAM role that allowsbedrock:InvokeModelon specific model ARNs.
3. Tokens and money
A token is a small piece of text counted by the model. It may be a whole word or part of one. A brief reply can still have a large input if the app sent a long ticket history. Try reading a sample with 300 input tokens and 30 output tokens. Shortening the expected reply only addresses the 30-token part. To address the 300, remove history the summariser does not need. For supported usage-based pricing, check the selected model’s input and output rates separately before estimating a batch of tickets.
You usually pay per input token and per output token. Long prompts + long answers + many test loops = surprise bills. Set budgets and alarms.
Lab discipline
Before any Bedrock lab: enable only one cheap model, set an AWS Budget alert (for example $5), keep max_tokens small, and never put Bedrock calls in an unbounded loop. If your org blocks Bedrock, skip the live call — reading this chapter is enough for the quiz.
4. Safety extras
Use fictional help-desk messages to check the behavior before using real tickets. Write one ordinary message and a second message that contains a value your selected guardrail should mask. Predict the summary and the expected guardrail action separately. A returned summary can sound certain while giving a wrong date, so compare factual details with the original text. Check permissions and data-handling rules around the model call too. A content filter addresses the text it evaluates, and the application remains responsible for how it handles the result.
- Guardrails: filter topics/PII patterns before/after the model.
- Least-privilege IAM on model IDs — not
*. - Do not send secrets or customer passwords in prompts.
- Log prompts carefully — they may contain personal data.
5. Bedrock vs SageMaker (again)
| Goal | Prefer |
|---|---|
| Chat, summarise, embed with a managed FM | Bedrock |
| Train a custom tabular/CV model on your labelled data | SageMaker |
| Fine-tune / customise some FMs on Bedrock where offered | Bedrock customisation features |
| Full training loop + custom containers | SageMaker |
6. Interview angles
Q. Do you manage GPUs for base FM calls?
No — Bedrock hosts the model.
Q. Main API family?
bedrock-runtime InvokeModel / Converse APIs.
Q. How billed?
Primarily tokens (plus optional extras).
Q. Guardrails?
Managed filters around model I/O.
Q. SageMaker instead?
When you must train/host your own model deeply.
Try at home
- Read current Bedrock pricing page for one model — note input vs output rates.
- Draft an IAM policy that allows InvokeModel on a single model ARN only.
In short
- Bedrock = foundation model APIs on AWS.
- Enable model access; use bedrock-runtime.
- Tokens cost money — budgets and small max_tokens.
- Prefer Bedrock for generative APIs; SageMaker for custom training.
Practise this chapter
Interview questions and answers
A model-generated help desk summary names the wrong room. What do you verify?
Compare the summary with the source and identify the unsupported detail. Check model output and stop reason, then improve or reject the result using the app’s validation. A guardrail can evaluate configured content concerns, while verifying the actual room requires grounding in the original ticket or other trusted data.
Check your understanding
Choose an answer, then compare your reasoning with the explanation.
Apply the concepts
Write one accepted model response and one rejected response for the projector ticket. Use an explanation that names the exact evidence in the source.
Check your result
The accepted response preserves Monday, projector failure and Room 204. The rejected response introduces an unsupported room, date or cause. The explanation identifies exactly which detail needs correction.
Read a Bedrock inference request and check its result
Before you start
- Use the fictional messages below and paper or a text editor. No credentials, model access or AWS account are required.
- Keep the system instruction and user message separate in your sketch.
Write the user message: 'The classroom projector failed on Monday. The trainer moved to Room 204.' Write an instruction to summarise in one sentence using only stated facts.
Expected result: The user text contains two facts. The instruction limits format and forbids adding unstated details.
Sketch a Converse request with a model ID placeholder, the instruction, one user message and an output length limit. Use a response containing 'On Monday the projector failed, so the class moved to Room 204.'
Expected result: The request separates the selected model, system instruction, content and inference configuration. The response preserves the day, fault and room.
Use dummy usage fields of 80 input tokens and 19 output tokens. If 10 identical-length calls run, calculate both totals separately. Now compare a shorter output of 9 tokens each.
Expected result: The ten originals total 800 input and 190 output tokens. Shortening the output lowers that total to 90 output tokens while input remains 800.
Add a second fictional input containing a value that a configured sensitive-information policy is meant to mask. Sketch the app handling the guardrail outcome, and separately compare a model response that mistakenly says Room 240.
Expected result: You can distinguish a guardrail intervention from a factual error. The app needs its own checks to ensure the room matches the supplied ticket.
If the result differs
- If you mixed input and output tokens, read the two usage fields separately before multiplying by the call count.
- When the response hallucinates a new detail, trace it back to the exact source sentence and decide how to reject or correct it.
Finish and clean up
- Remove temporary copies of the dummy messages after your review. No model invocation or cloud resources were created.
Practice Tasks
Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.
About this scenarioSolapur Chaddar House is a home textiles business in Solapur. Vikas Kamble looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 10
Easy List Bedrock models
See which foundation models are offered in your Region.
List the foundation models available in Amazon Bedrock.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy List SageMaker endpoints
Endpoints cost money every hour; list them to find forgotten ones.
List SageMaker endpoints.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy How many addresses in a /16?
Picking a VPC size needs this count.
Solapur Chaddar House plans the VPC 10.86.0.0/16. How many IP addresses does it hold in total?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy Port for SSH
Security group rules need the right port.
Which TCP port must the security group open for SSH?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy Show where you are
Before you copy or delete anything, you must know which folder you are in.
Vikas Kamble logged in to the Solapur Chaddar House server and is not sure which folder the terminal is in. Print the current folder path.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Easy Read-only access to one bucket
Least privilege: give only the actions and the bucket the job needs.
Write an identity policy that lets the user read objects (s3:GetObject) only in bucket solapurchaddar-data.
- Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
- In each statement write Effect, Action and Resource.
- Give only what the task needs (least privilege).
- Use double quotes and commas correctly. Click Check answer.
Medium Detect labels in an image
Rekognition names objects in a photo, e.g. to tag product images.
Detect labels in s3://solapurchaddar-media/shop/p1.jpg (Bucket=solapurchaddar-media, Name=shop/p1.jpg), max 10 labels.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Allow one Bedrock model
Limit apps to the approved model so costs stay predictable.
Allow bedrock:InvokeModel on arn:aws:bedrock:ap-south-1::foundation-model/amazon.nova-lite-v1:0 only.
- Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
- In each statement write Effect, Action and Resource.
- Give only what the task needs (least privilege).
- Use double quotes and commas correctly. Click Check answer.
Medium Usable IPs in an AWS /24 subnet
AWS keeps 5 addresses in every subnet.
How many addresses can Solapur Chaddar House use for servers in subnet 10.86.1.0/24 on AWS?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Hard Ask a model a question
Converse is one API shape for many models.
Call converse on model amazon.nova-lite-v1:0 with the messages in msgs.json.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Revision, comparison and interview cards
Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.






More cards: Ravi Sir's Cards.