Map a chat app to Amazon Bedrock API operations - Amazon Bedrock Studio

Amazon Bedrock Studio, renamed to Amazon Bedrock IDE, is now available in Amazon SageMaker Unified Studio. Amazon Bedrock Studio will be available until February 28, 2025. You may access existing workspaces in this previous version through February 28, 2025, but you may not create new workspaces. To access the enhanced GA version of Amazon Bedrock Studio with additional features and capabilities, you can create a new Amazon SageMaker Unified Studio domain. To learn about Amazon Bedrock Studio IDE, see the documentation.

Map a chat app to Amazon Bedrock API operations

A chat app that you export from Amazon Bedrock Studio works by making calls to various Amazon Bedrock operations. In general, an Amazon Bedrock Studio chat app uses the inference operations or the agent operations to send chat messages to a model. The components that an app uses, such as a Knowledge Base, determines which operations are used. This section maps chat app component configurations to the underlying Amazon Bedrock Studio API operations.

When you export a chat app, you can see the operations that the app calls in the code-snippet.mjs source code file that the export creates.

Chat app with no components

A simple chat app without any components calls the InvokeModelWithResponseStream inference operation to send chat messages to the model and stream the response back. If the model doesn't support streaming, the app uses the InvokeModel operation instead. The operations both use the inference parameters that you configure for the app.

Note

Amazon Bedrock also provides the Converse API as an alternative method for sending messages to a model.

For more information, see Run model inference in the Amazon Bedrock guide.

Chat app with guardrail component

If a chat app uses a guardrail component (and no other components), it calls the InvokeModelWithResponseStream or InvokeModel inference operation (if the model doesn't support streaming). In the operation request, the app specifies the guardrail ID for the guardrail that safeguards the app. If the app also uses other components, other Amazon Bedrock operations might be used instead.

Note

If you use the Converse API, you can also specify a guardrail that the app uses.

For more information, see Guardrails for Amazon Bedrock in the Amazon Bedrock guide.

Chat app with data source component

A chat app can have one of two types of data source – a document file or an Amazon Bedrock Knowledge Base. In both cases, the app uses RetrieveAndGenerate agents operation to send a message and document data source details to the model. The model then generates a response based on the information in the data source.

You can't use a guardrail with an Amazon Bedrock Studio chat app that uses a data source. In your own applications, you can configure a guardrail to safeguard responses for calls you make to RetrieveAndGenerate.

If you chat also uses a function component, see Chat app with function and data source component.

For more information, see Knowledge bases for Amazon Bedrock in the Amazon Bedrock guide.

Chat app with function component

You can set up a chat app to use a function component that calls an external API. In this scenario, the app uses an Amazon Bedrock agent to chat with the model. To send a message to the agent, the chat app uses the InvokeAgent agent operation. Based on the message content, the agent might use the function component to help meet the message requirements.

If you chat also uses a data source component, see Chat app with function and data source component.

For more information, see Agents for Amazon Bedrock in the Amazon Bedrock guide.

Chat app with function and data source component

If your app uses a function component and a data source component, its uses an Amazon Bedrock agent to chat with the model. To send a message to the agent, the chat app uses the InvokeAgent agent operation. The app uses the data source and the function component to help meet the requirements of the message.

For more information, see Agents for Amazon Bedrock in the Amazon Bedrock guide.