Lesson 1 of 5 Amazon Bedrock

Calling Foundation Models on Amazon Bedrock

This lesson explains how Amazon Bedrock, the fully managed, serverless way to build generative AI applications on AWS, gives access to foundation models from Amazon and leading AI companies through one API, with no infrastructure to manage.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the range of foundation models available on Bedrock.
  • Distinguish the InvokeModel API from the Converse API.
  • Explain how temperature, top p and maximum tokens affect a model's output.
  • Describe how Bedrock protects data and logs model invocations.

Available models

Amazon Bedrock offers foundation models from Amazon and other providers through one service, so an application can use several models without separate contracts, infrastructure or APIs. Amazon's own Nova family covers text, multi-modal understanding and speech, and Titan provides embedding models. (Nova Canvas and Nova Reel, Amazon's image and video generation models, reached end of life on 30 September 2026.) Models from other providers include Anthropic's Claude, Meta's Llama, Mistral AI, Cohere, DeepSeek, Stability AI for images and Luma AI for video. Because the models differ in quality, speed and price, choosing a model is a trade-off for each use case. The following table summarises the providers.

ProviderModels
AmazonNova family (text, multi-modal and speech) and Titan embeddings
OthersAnthropic (Claude), Meta (Llama), Mistral AI, Cohere, DeepSeek, Stability AI (images), Luma AI (video) and more

You can switch models without changing infrastructure and compare them in the console playgrounds. Bedrock Marketplace adds specialised models.

Calling models

Applications call Bedrock models through two main APIs. InvokeModel sends a request in the model's own native format, which differs from one provider to another, so switching models means changing the request code. The Converse API uses one consistent format for every model, with a system prompt, a list of messages for multi-turn conversations, and support for images, documents and tool use, also called function calling, in which the model asks the application to run a function and uses the result. With Converse, changing models is usually just changing the model ID. The following table summarises the two APIs.

APIWhat it does
InvokeModelSends a request in each model's native format
Converse APIOne consistent format across all models, with system prompts, multi-turn messages, images, documents and tool use (function calling)

Streaming versions of both return tokens as they are generated.

Scenario questions

Choosing a Bedrock API

Exam skills 2.3.1

Choose the way to call models for each requirement.

Log in to try this activity Interactive activities are free with an account.

Inference parameters

A model generates text one token, roughly a word or part of a word, at a time, choosing each from a range of likely options, and inference parameters control that choice. Temperature sets how random the choice is: a low value, such as 0 to 0.3, makes the model pick the most likely tokens, giving focused and consistent answers, which suits factual tasks; a high value, such as 0.7 to 1, gives more varied and creative output. Top P limits the choice to the most likely tokens whose probabilities add up to P, and Top K limits it to the K most likely tokens.

Maximum tokens caps the length of the response, which also limits cost, since output is charged per token. Stop sequences end generation as soon as a chosen string appears. The following table summarises the parameters.

ParameterEffect
TemperatureRandomness: low (0–0.3) gives focused, consistent answers; high (0.7–1) gives varied, creative output
Top PLimits choice to the most likely tokens whose probabilities add up to P
Top KLimits choice to the K most likely tokens
Maximum tokensCaps response length, and so cost
Stop sequencesEnd generation when a given string appears

The following diagram shows how temperature reshapes the next-token probabilities.

What temperature does to the choice of the next token. A low temperature, around 0 to 0.3, sharpens the distribution so the most likely token is chosen almost every time, which suits factual tasks. A high temperature, around 0.7 to 1, flattens it so less likely tokens are chosen more often, giving varied, creative output. Top P and Top K limit which tokens can be chosen, maximum tokens caps the length and cost, and stop sequences end generation.
Use a low temperature for factual tasks.
Match the pairs

Inference parameters

Exam skills 3.1.2

Match each inference parameter with its effect.

Log in to try this activity Interactive activities are free with an account.

Data protection and logging

Amazon Bedrock protects the data sent to models and can record model invocations. The following list describes these protections and logging features.

  • Prompts and responses are not used to train base models and not shared with model providers.
  • Data is encrypted in transit and at rest, optionally with your own KMS keys, and processed in the Regions you choose.
  • Cross-Region inference profiles route requests across Regions in a geography for more throughput.
  • Model invocation logging records requests and responses to CloudWatch Logs or S3 for auditing.

Further features build on the models: Knowledge Bases, Agents, Guardrails, Prompt Management, Flows, model evaluation and customisation.

True or false

Protecting data in Bedrock

Exam skills 2.3.3 · 5.1.1

Check three claims about data protection and logging in Amazon Bedrock.

Log in to try this activity Interactive activities are free with an account.
Worked example

One request, two temperatures

A developer calls a model on Bedrock through the Converse API. The request has the same shape for every chat model, which is why switching models needs no code changes:

import boto3

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

def ask(prompt, temperature):
    response = bedrock.converse(
        modelId="us.amazon.nova-2-lite-v1:0",
        system=[{"text": "You are a concise assistant for a bank."}],
        messages=[{"role": "user", "content": [{"text": prompt}]}],
        inferenceConfig={"temperature": temperature, "maxTokens": 200},
    )
    return response["output"]["message"]["content"][0]["text"]

ask("What documents do I need to open an account?", temperature=0.1)   # factual: low temperature
ask("Suggest a friendly name for our savings app.", temperature=0.9)    # creative: high temperature

For the factual question the bank wants the same accurate answer every time, so it uses a low temperature. For brainstorming it wants variety, so it raises the temperature. Max tokens caps the length, and therefore the cost, of every answer. None of these prompts is used to train the model or shared with the model provider.

Check yourself

Does Amazon Bedrock use customers' prompts to train the base models?

Show answer

No. Prompts and responses are not used to train AWS or third-party base models, and they stay in the Region unless cross-Region inference is chosen.

Exam Tips

Remember for the exam

  • Many foundation models through one API, with no infrastructure, points to Amazon Bedrock.
  • One request format across models, including tool use, is the Converse API.
  • For consistent, factual output use a low temperature; for creative output use a higher one.
  • To limit response length and cost, set maximum tokens.
  • Bedrock does not use your prompts to train base models and does not share them with model providers.
  • To audit prompts and responses, enable model invocation logging.