Machine Learning

Introduction to AWS Bedrock | About Data Science

in early 2026, AWS has several related yet distinct components that make up its agent and LLM summaries.

  • Bedrock a model layer that allows access to large language models.
  • Bedrock Agents managed application layer. In other words, AWS works for you agents according to your needs.
  • Bedrock AgentCore is an infrastructure layer that allows AWS to run agents that you develop using third-party frameworks such as CrewAI and LangGraph.

Apart from these three services, AWS also has them fibers, an open-source Python library for building out-of-service Bedrock agents, which can be embedded in other AWS services such as ECS and Lambda.

It can be confusing because all three agency-based services have the word “Bedrock” in their names, but in this article, I will focus on the most common Bedrock service and show how and why you can use it. standard Bedrock service and show how and why to use it.

As a service, Bedrock has been available exclusively on AWS since early 2023. That should give you a clue as to why it was introduced. Amazon can clearly see the rise of macro-language models and their impact on IT architecture and the software development process. That's the meat and potatoes of AWS, and they were determined that no one was going to eat their lunch.

And while AWS has developed a few of its LLMs, it realized that to stay competitive, it would have to make more advanced models, like those from Anthropic, available to users. That's where Bedrock comes in. As they said in their teaser on their website,

… Bedrock is a fully managed service that offers a selection of efficient foundation models (FMs) from leading AI companies such as AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon through a single API, and the comprehensive set of skills you need to build productive AI applications, simplify development while maintaining privacy and security.

How do I log in to Bedrock?

Okay, so that's the idea behind why Bedrock, but how do we get access to it and actually use it? Unsurprisingly, the first thing you need is an AWS account. I'll assume you already have this, but if not, click the following link to set it up.

Usefully, after signing up for a new AWS account, a good number of the services you use will fall under the so-called “free category” at AWS, which means that your costs should be very low. one year following the creation of your account – you think you are not crazy and start shooting big computer servers and the like.

There are three main ways to use AWS services.

  • With the console. If you are just starting out, this will probably be your preferred route as it is the easiest way to get started.
  • Through the API. If you can code, you can access all AWS services through API. For example, for Python programmers, AWS provides both 3 the library. There are similar libraries for other languages, such as JavaScript, etc.
  • Through the command line interface (CLI). The CLI is an additional tool that you can download from AWS and allows you to interact with AWS resources from your terminal.

Note that, to use the last two methods, you must have login credentials set up in your local system.

What can I do with Bedrock?

The short answer is that you can do a lot of things with standard dialog models from OpenAI, Anthropic, Google, and so on. Underly Bedrock has basic models that you can use as well, such as:-

  • For me K2 Thinking. A deep thinking model
  • Claude Opus 4.5. For many people, this is the top LLM available to date.
  • GPT-OSS. OpenAI's open source LLM

And many, many more besides. For the full list, check out the following link.

How do I use Bedrock?

To use Bedrock, we will use a mixture of the AWS CLI and the Python API provided by the boto3 library. Make sure you have the following setup as required

  • AWS account.
  • The AWS CLI has been downloaded and installed on your system.
  • An Identity and Access Management (IAM) user is set up with appropriate permissions and access keys. You can do this through the AWS console.
  • Configure your user credentials through the AWS CLI as follows. Generally, three pieces of information need to be provided. All this you will find in the previous step above. You will be asked to enter the correct information,
$ aws configure

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]:

It gives Bedrock access to the model

Back in the day (a few months ago!), you had to use the AWS management console to request access to certain models from Bedrock, but now access is automatically granted when you request a model for the first time.

Note that for Anthropic models, first users may need to submit use case information before they can access the model. Also note that access to top models from Anthropic and other suppliers the willenter the costs so please make sure you monitor your charge regularly and delete any model access you no longer need.

However, we still need to know the name of the model we want to use. To get a list of all models compatible with Bedrock, we can use the following AWS CLI command.

aws bedrock list-foundation-models

This will return a JSON result set that lists the various properties of each model, like this.

{
    "modelSummaries": [
        {
            "modelArn": "arn:aws:bedrock:us-east-2::foundation-model/nvidia.nemotron-nano-12b-v2",
            "modelId": "nvidia.nemotron-nano-12b-v2",
            "modelName": "NVIDIA Nemotron Nano 12B v2 VL BF16",
            "providerName": "NVIDIA",
            "inputModalities": [
                "TEXT",
                "IMAGE"
            ],
            "outputModalities": [
                "TEXT"
            ],
            "responseStreamingSupported": true,
            "customizationsSupported": [],
            "inferenceTypesSupported": [
                "ON_DEMAND"
            ],
            "modelLifecycle": {
                "status": "ACTIVE"
            }
        },
        {
            "modelArn": "arn:aws:bedrock:us-east-2::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0",
...
...
...

Choose the model you need and take care of it modelID from the JSON output, as we will need this in our Python code later. An important caveat to this is that you often see the following in the model description,

...
...
"inferenceTypesSupported": [
    "INFERENCE_PROFILE"
]
...
...

This is reserved for the following models:

  • They are large or highly sought after
  • It requires a reserved or managed dose
  • You need clear cost and exit controls

For these models, we cannot simply refer to the modelID in our code. Instead, we need to refer to an inference profile. An inference profile is a Bedrock resource tied to one or more basic and regional LLMs.

There are two ways to find an inference profile that you can use. The first is to do it yourself. These are called Program Profiles. The second way is to use one of the AWS supported profiles. This is an easy option, as it is pre-built for you and you just need to find the correct profile ID associated with the inference profile you will use in your code.

If you want to take the approach of creating your own application profile, check out the relevant AWS documentation, but I'll use a profile based on my example code.

For a list of supported profiles in AWS, see the link below:

For my first code example, I want to use Claude's Sonnet 3.5 V2 model, so I clicked on the line above and saw the following description.

Image from the AWS website

I noticed the profile ID ( us.anthropic.claude-3–5-sonnet-20241022-v2:0 ) and one of the valid source regions ( us-east-1 )

In my two code example snippets, I'll use OpenAI's open source LLM to generate text and AWS's Titan Image generator for images. None of these models require an inference profile, so you can use their standard model in your code.

NOTE: Whichever model you choose, make sure your AWS region is set to the correct value for each one.

Setting Up the Development Environment

Since we're going to do some coding, it's best to isolate your location so we don't interfere with any of our other projects. So let's do that now. I use Windows and the UV package manager for this, but use whatever tool you're comfortable with. My code will run in a Jupyter notebook.

uv init bedrock_demo --python 3.13
cd bedrock_demo
uv add boto3 jupyter

# To run the notebook, type this in
uv run jupyter notebook

Using Bedrock from Python

Let's see Bedrock in action with a few examples. The first one will be simple, and we will gradually increase the complexity as we go.

Example 1: A simple question and answer using an inference profile

This example uses the Claude Sonnet 3.5 V2 model we talked about earlier. As mentioned, to request this model, we use the profile ID associated with its logic profile.

import json
import boto3

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

profile_id = "us.anthropic.claude-3-5-sonnet-20241022-v2:0"

body = json.dumps({
    "anthropic_version": "bedrock-2023-05-31",
    "max_tokens": 200,
    "temperature": 0.2,
    "messages": [
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What is the capital of France?"}
            ]
        }
    ]
})

resp = brt.invoke_model(
    modelId=profile_id,
    body=body,
    accept="application/json",
    contentType="application/json"
)

data = json.loads(resp["body"].read())

# Claude responses come back as a "content" array, not OpenAI "choices"
print(data["content"][0]["text"])

#
# Output
#
The capital of France is Paris.

Note that requesting this model (and others like it) creates an implied subscription between you and the AWS marketplace. This not standard recurring charge. It costs you only when the model is actually used, but it is best to monitor this to avoid unexpected bills. You should receive an email explaining the subscription agreement, with a link to manage and/or cancel any existing subscriptions for preset models.

Example 2: Create an image

Simple image creation using the AWS Titan model. This model is not related to the inference profile, so we can just reference it using its modelID.

import json
import base64
import boto3

brt_img = boto3.client("bedrock-runtime", region_name="us-east-1")
model_id_img = "amazon.titan-image-generator-v2:0"

prompt = "A hippo riding a bike."

body = json.dumps({
    "taskType": "TEXT_IMAGE",
    "textToImageParams": {
        "text": prompt
    },
    "imageGenerationConfig": {
        "numberOfImages": 1,
        "height": 1024,
        "width": 1024,
        "cfgScale": 7.0,
        "seed": 0
    }
})

resp = brt_img.invoke_model(
    modelId=model_id_img,
    body=body,
    accept="application/json",
    contentType="application/json"
)

data = json.loads(resp["body"].read())

# Titan returns base64-encoded images in the "images" array
img_b64 = data["images"][0]
img_bytes = base64.b64decode(img_b64)

out_path = "titan_output.png"
with open(out_path, "wb") as f:
    f.write(img_bytes)

print("Saved:", out_path)

On my system, the output image looked like this.

Image via AWS Titan LLM

Example 3: A third-party technical support assistant uses OpenAI's OSS model

This is a complex and useful example. Here, we set up an assistant that will take problems reported to it by non-technical users and issue additional questions that you may want the user to answer, as well as possible causes of the problem and what steps to take. Like our previous example, this model is not associated with an inference profile.

import json
import re
import boto3
from pydantic import BaseModel, Field
from typing import List, Literal, Optional

# ----------------------------
# Bedrock setup
# ----------------------------
REGION = "us-east-2"
MODEL_ID = "openai.gpt-oss-120b-1:0"

brt = boto3.client("bedrock-runtime", region_name=REGION)

# ----------------------------
# Output schema
# ----------------------------
Severity = Literal["low", "medium", "high"]
Category = Literal["account", "billing", "device", "network", "software", "security", "other"]

class TriageResponse(BaseModel):
    category: Category
    severity: Severity
    summary: str = Field(description="One-sentence restatement of the problem.")
    likely_causes: List[str] = Field(description="Top plausible causes, concise.")
    clarifying_questions: List[str] = Field(description="Ask only what is needed to proceed.")
    safe_next_steps: List[str] = Field(description="Step-by-step actions safe for a non-technical user.")
    stop_and_escalate_if: List[str] = Field(description="Clear red flags that require a professional/helpdesk.")
    recommended_escalation_target: Optional[str] = Field(
        default=None,
        description="If severity is high, who to contact (e.g., IT admin, bank, ISP)."
    )

# ----------------------------
# Helpers
# ----------------------------
def invoke_chat(messages, max_tokens=800, temperature=0.2) -> dict:
    body = json.dumps({
        "messages": messages,
        "max_tokens": max_tokens,
        "temperature": temperature
    })

    resp = brt.invoke_model(
        modelId=MODEL_ID,
        body=body,
        accept="application/json",
        contentType="application/json"
    )
    return json.loads(resp["body"].read())

def extract_content(data: dict) -> str:
    return data["choices"][0]["message"]["content"]

def extract_json_object(text: str) -> dict:
    """
    Extract the first JSON object from model output.
    Handles common cases like  blocks or extra text.
    """
    text = re.sub(r".*?", "", text, flags=re.DOTALL).strip()

    start = text.find("{")
    if start == -1:
        raise ValueError("No JSON object found.")

    depth = 0
    for i in range(start, len(text)):
        if text[i] == "{":
            depth += 1
        elif text[i] == "}":
            depth -= 1
            if depth == 0:
                return json.loads(text[start:i+1])

    raise ValueError("Unbalanced JSON braces; could not parse.")

# ----------------------------
# The useful function
# ----------------------------
def triage_issue(user_problem: str) -> TriageResponse:
    messages = [
        {
            "role": "system",
            "content": (
                "You are a careful technical support triage assistant for non-technical users. "
                "You must be conservative and safety-first. "
                "Return ONLY valid JSON matching the given schema. No extra text."
            )
        },
        {
            "role": "user",
            "content": f"""
User problem:
{user_problem}

Return JSON that matches this schema:
{TriageResponse.model_json_schema()}
""".strip()
        }
    ]

    raw = invoke_chat(messages)
    text = extract_content(raw)
    parsed = extract_json_object(text)
    return TriageResponse.model_validate(parsed)

# ----------------------------
# Example
# ----------------------------
if __name__ == "__main__":
    problem = "My laptop is connected to Wi-Fi but websites won't load, and Zoom keeps saying unstable connection."
    result = triage_issue(problem)
    print(result.model_dump_json(indent=2))

Here is the output.

"category": "network",
  "severity": "medium",
  "summary": "Laptop shows Wi‑Fi connection but cannot load websites and Zoom 
              reports an unstable connection.",
  "likely_causes": [
    "Router or modem malfunction",
    "DNS resolution failure",
    "Local Wi‑Fi interference or weak signal",
    "IP address conflict on the network",
    "Firewall or security software blocking traffic",
    "ISP outage or throttling"
  ],
  "clarifying_questions": [
    "Are other devices on the same Wi‑Fi network able to access the internet?",
    "Did the problem start after any recent changes (e.g., new software, OS update, VPN installation)?",
    "Have you tried moving closer to the router or using a wired Ethernet connection?",
    "Do you see any error codes or messages in the browser or Zoom besides "unstable connection"?"
  ],
  "safe_next_steps": [
    "Restart the router and modem by unplugging them for 30 seconds, then power them back on.",
    "On the laptop, forget the Wi‑Fi network, then reconnect and re-enter the password.",
    "Run the built‑in Windows network troubleshooter (Settings → Network & Internet → Status → Network troubleshooter).",
    "Disable any VPN or proxy temporarily and test the connection again.",
    "Open a command prompt and run `ipconfig /release` followed by `ipconfig /renew`.",
    "Flush the DNS cache with `ipconfig /flushdns`.",
    "Try accessing a simple website (e.g.,  and note if it loads.",
    "If possible, connect the laptop to the router via Ethernet to see if the issue persists."
  ],
  "stop_and_escalate_if": [
    "The laptop still cannot reach any website after completing all steps.",
    "Other devices on the same network also cannot access the internet.",
    "You receive error messages indicating hardware failure (e.g., Wi‑Fi adapter not found).",
    "The router repeatedly restarts or shows error lights.",
    "Zoom continues to report a poor or unstable connection despite a working internet test."
  ],
  "recommended_escalation_target": "IT admin"
}

Summary

This article was introduced AWS Bedrock, An AWS-managed gateway to support major language models, explains why it exists, and how it fits into the scope. The AWS AI stack, and how to use it in practice. We've covered model discovery, region and validation setup, and the key differences between on-demand models and those that require assumed profiles – a common source of developer confusion.

With working Python examples, we have demonstrated text and image generation using both the required input models and those that require an inference profile.

At its core, Bedrock reflects the classic AWS philosophy: abstract infrastructure complexity without removing control. Rather than pushing a single “best” model, Bedrock treats the underlying models as components of a managed infrastructure – scalable, controllable, and region-aware. This suggests a future where Bedrock evolves less as a conversational interface and more as a model orchestration layer, tightly integrated with IAM, network, cost controls, and agent frameworks.

Over time, we can expect Bedrock to move toward limited (subscription) contracts and a clear separation between exploration and production capacity. And with their Agent and AgentCore services, we are already seeing deep integration of agent workflows with Bedrock, models positioned not as products in themselves but as solid building blocks within AWS systems.


For the avoidance of doubt, unless I am a user of their services, I have no connection or association with Amazon Web Services.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button