Carry out a conversation with the Converse API operations
You can use the Amazon Bedrock Converse API to create conversational applications that send and receive messages to and from an Amazon Bedrock model. For example, you can create a chat bot that maintains a conversation over many turns and uses a persona or tone customization that is unique to your needs, such as a helpful technical support assistant.
To use the Converse API, you use the Converse or ConverseStream (for streaming responses) operations to send messages to a model. It is possible to use the existing base inference operations (InvokeModel or InvokeModelWithResponseStream) for conversation applications. However, we recommend using the Converse API as it provides consistent API, that works with all Amazon Bedrock models that support messages. This means you can write code once and use it with different models. Should a model have unique inference parameters, the Converse API also allows you to pass those unique parameters in a model specific structure.
You can use the Converse API to implement tool use and guardrails in your applications.
Note
With Mistral AI and Meta models, the Converse API embeds your input in a model-specific prompt template that enables conversations.
For code examples, see the following:
-
Python examples for this topic – Converse API examples
-
Various languages and models – Code examples for Amazon Bedrock Runtime using AWS SDKs
-
Java tutorial – A Java developer's guide to Bedrock's new Converse API
-
JavaScript tutorial – A developer's guide to Bedrock's new Converse API