3 Building Applications with the Amazon Bedrock API

 

This chapter covers

  • Making your first API calls with Amazon Bedrock
  • Coding solutions for textual and image models
  • Applying prompt engineering knowledge
  • Calling different foundational models with the API
  • Building your first application with Amazon Bedrock API

Many practitioners have found a variety of uses for Generative AI; whether it be to act as a personal assistant, helping them generate content, and many more. This involves the integration of the APIs used to call the foundational models into the applications which the users must perform the actions required. In the previous chapter, we looked at prompt engineering, which is crucial to learn before working with APIs because it provides a deep understanding of how to effectively communicate with the model to get accurate and relevant responses. This foundational knowledge ensures that users can optimize their interactions, making the most of the API's capabilities and achieving better outcomes in their applications. In this chapter, we will delve into how to start using the Amazon Bedrock API for your own use cases, building the foundation for what will later be building full-fledged applications with integrated Generative AI capabilities. We will walk through the foundational concepts necessary to use the API, how to call the API, and then implement a couple of solutions with it, such as a food recommender and with generating images.

3.1 Overview of Utilizing the Amazon Bedrock API

3.1.1 API Endpoints for Using Amazon Bedrock

3.1.2 Invoking the Model

3.2 Using Textual Models through the API

3.2.1 Configuring the Appropriate Parameters

3.2.2 Formatting the Right API Calls

3.2.3 Streaming Responses

3.2.4 Handling Exceptions

3.3 Using Stable Diffusion for Image Generation

3.3.1 Inference Parameters

3.3.2 Using the Amazon Bedrock Image Playground

3.3.3 Coding up Text to Image Implementation

3.4 Maintaining Context in Generative AI Chatbots

3.5 Understanding the Needs of a Generative AI Web Application

3.6 Building Your First Generative AI Flask Application

3.7 Summary