Module 3 Wrap-up: Your First AI Call
·AWS Bedrock

Module 3 Wrap-up: Your First AI Call

Hands-on: Write a script that compares the outputs of two different models using the same prompt.

Module 3 Wrap-up: The API Developer

You have graduated from the AWS Console to the Python IDE. You understand the difference between the low-level InvokeModel (Control) and the high-level Converse (Unified) APIs. You are now ready to build scalable, multi-model applications.


Hands-on Exercise: The Model Duel

1. The Goal

Create a Python script that takes a prompt and sends it to Llama 3 8B and Claude 3 Haiku using the Converse API.

2. The Implementation Plan

  1. Define a prompt variable.
  2. Write a function call_bedrock(model_id, prompt).
  3. Call the function twice.
  4. Print the results side-by-side.

3. Key Discovery

Notice how the output "Vibe" changes even though the code is identical except for the modelId.


Module 3 Summary

  • Boto3: The AWS SDK for Python.
  • Bedrock-Runtime: The client used for model execution.
  • Converse API: The future-proof way to build text applications.
  • Consistency: Unified APIs allow for rapid model switching and testing.
  • Error Handling: Watching for Throttling and Validation exceptions.

Coming Up Next...

In Module 4, we focus on the "Data" we send to these APIs: Prompt Engineering. We will learn how to use System Messages and Guardrails in Bedrock to ensure our AI stays on-task and professional.


Module 3 Checklist

  • I have installed boto3.
  • I can explain the difference between InvokeModel and Converse.
  • I have successfully run a Python script that calls a Bedrock model.
  • I can find the text content inside a Converse API response object.
  • I understand how to set maxTokens and temperature.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn