Converse - Amazon Bedrock


Sends messages to the specified Amazon Bedrock model. Converse provides a consistent interface that works with all models that support messages. This allows you to write code once and use it with different models. If a model has unique inference parameters, you can also pass those unique parameters to the model.

Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to generate the response.

For information about the Converse API, see Use the Converse API. To use a guardrail, see Use a guardrail with the Converse API. To use a tool with a model, see Tool use (Function calling).

For example code, see Converse API examples.

This operation requires permission for the bedrock:InvokeModel action.

Request Syntax

POST /model/modelId/converse HTTP/1.1 Content-type: application/json { "additionalModelRequestFields": JSON value, "additionalModelResponseFieldPaths": [ "string" ], "guardrailConfig": { "guardrailIdentifier": "string", "guardrailVersion": "string", "trace": "string" }, "inferenceConfig": { "maxTokens": number, "stopSequences": [ "string" ], "temperature": number, "topP": number }, "messages": [ { "content": [ { ... } ], "role": "string" } ], "system": [ { ... } ], "toolConfig": { "toolChoice": { ... }, "tools": [ { ... } ] } }

URI Request Parameters

The request uses the following URI parameters.


The identifier for the model that you want to call.

The modelId to provide depends on the type of model that you use:

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: ^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:provisioned-model/[a-z0-9]{12})))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)$

Required: Yes

Request Body

The request accepts the following data in JSON format.


Additional inference parameters that the model supports, beyond the base set of inference parameters that Converse supports in the inferenceConfig field. For more information, see Model parameters.

Type: JSON value

Required: No


Additional model parameters field paths to return in the response. Converse returns the requested fields as a JSON Pointer object in the additionalModelResponseFields field. The following is example JSON for additionalModelResponseFieldPaths.

[ "/stop_sequence" ]

For information about the JSON Pointer syntax, see the Internet Engineering Task Force (IETF) documentation.

Converse rejects an empty JSON Pointer or incorrectly structured JSON Pointer with a 400 error code. if the JSON Pointer is valid, but the requested field is not in the model response, it is ignored by Converse.

Type: Array of strings

Array Members: Minimum number of 0 items. Maximum number of 10 items.

Length Constraints: Minimum length of 1. Maximum length of 256.

Required: No


Configuration information for a guardrail that you want to use in the request.

Type: GuardrailConfiguration object

Required: No


Inference parameters to pass to the model. Converse supports a base set of inference parameters. If you need to pass additional parameters that the model supports, use the additionalModelRequestFields request field.

Type: InferenceConfiguration object

Required: No


The messages that you want to send to the model.

Type: Array of Message objects

Required: Yes


A system prompt to pass to the model.

Type: Array of SystemContentBlock objects

Required: No


Configuration information for the tools that the model can use when generating a response.


This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.

Type: ToolConfiguration object

Required: No

Response Syntax

HTTP/1.1 200 Content-type: application/json { "additionalModelResponseFields": JSON value, "metrics": { "latencyMs": number }, "output": { ... }, "stopReason": "string", "trace": { "guardrail": { "inputAssessment": { "string" : { "contentPolicy": { "filters": [ { "action": "string", "confidence": "string", "type": "string" } ] }, "contextualGroundingPolicy": { "filters": [ { "action": "string", "score": number, "threshold": number, "type": "string" } ] }, "sensitiveInformationPolicy": { "piiEntities": [ { "action": "string", "match": "string", "type": "string" } ], "regexes": [ { "action": "string", "match": "string", "name": "string", "regex": "string" } ] }, "topicPolicy": { "topics": [ { "action": "string", "name": "string", "type": "string" } ] }, "wordPolicy": { "customWords": [ { "action": "string", "match": "string" } ], "managedWordLists": [ { "action": "string", "match": "string", "type": "string" } ] } } }, "modelOutput": [ "string" ], "outputAssessments": { "string" : [ { "contentPolicy": { "filters": [ { "action": "string", "confidence": "string", "type": "string" } ] }, "contextualGroundingPolicy": { "filters": [ { "action": "string", "score": number, "threshold": number, "type": "string" } ] }, "sensitiveInformationPolicy": { "piiEntities": [ { "action": "string", "match": "string", "type": "string" } ], "regexes": [ { "action": "string", "match": "string", "name": "string", "regex": "string" } ] }, "topicPolicy": { "topics": [ { "action": "string", "name": "string", "type": "string" } ] }, "wordPolicy": { "customWords": [ { "action": "string", "match": "string" } ], "managedWordLists": [ { "action": "string", "match": "string", "type": "string" } ] } } ] } } }, "usage": { "inputTokens": number, "outputTokens": number, "totalTokens": number } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.


Additional fields in the response that are unique to the model.

Type: JSON value


Metrics for the call to Converse.

Type: ConverseMetrics object


The result from the call to Converse.

Type: ConverseOutput object

Note: This object is a Union. Only one member of this object can be specified or returned.


The reason why the model stopped generating output.

Type: String

Valid Values: end_turn | tool_use | max_tokens | stop_sequence | guardrail_intervened | content_filtered


A trace object that contains information about the Guardrail behavior.

Type: ConverseTrace object


The total number of tokens used in the call to Converse. The total includes the tokens input to the model and the tokens generated by the model.

Type: TokenUsage object


For information about the errors that are common to all actions, see Common Errors.


The request is denied because of missing access permissions.

HTTP Status Code: 403


An internal server error occurred. Retry your request.

HTTP Status Code: 500


The request failed due to an error while processing the model.

HTTP Status Code: 424


The model specified in the request is not ready to serve inference requests.

HTTP Status Code: 429


The request took too long to process. Processing time exceeded the model timeout length.

HTTP Status Code: 408


The specified resource ARN was not found. Check the ARN and try your request again.

HTTP Status Code: 404


Your request was throttled because of service-wide limitations. Resubmit your request later or in a different region. You can also purchase Provisioned Throughput to increase the rate or number of tokens you can process.

HTTP Status Code: 429


Input validation failed. Check your request parameters and retry the request.

HTTP Status Code: 400


Send a message to a model

Send a messsage to Anthropic Claude Sonnet with Converse.

POST /model/anthropic.claude-3-sonnet-20240229-v1:0/converse HTTP/1.1 Content-type: application/json { "messages": [ { "role": "user", "content": [ { "text": "Write an article about impact of high inflation to GDP of a country" } ] } ], "system": [{"text" : "You are an economist with access to lots of data"}] "inferenceConfig": { "maxTokens": 1000, "temperature": 0.5 } }

Example response

Response for the above request.

HTTP/1.1 200 Content-type: application/json { "output": { "message": { "content": [ { "text": "<text generated by the model>" } ], "role": "assistant" } }, "stopReason": "end_turn", "usage": { "inputTokens": 30, "outputTokens": 628, "totalTokens": 658 }, "metrics": { "latencyMs": 1275 } }

Send a message with additional model fields

In the following example, the request passess a field (top_k) that the Converse field doesn't support. You pass the additional field in the additionalModelRequestFields field. The example also shows how to set the paths for the additional fields sent in the response from the model.

POST /model/anthropic.claude-3-sonnet-20240229-v1:0/converse HTTP/1.1 Content-type: application/json { "messages": [ { "role": "user", "content": [ { "text": "Provide general steps to debug a BSOD on a Windows laptop." } ] } ], "system": [{"text" : "You are a tech support expert who helps resolve technical issues. Signal 'SUCCESS' if you can resolve the issue, otherwise 'FAILURE'"}], "inferenceConfig": { "stopSequences": [ "SUCCESS", "FAILURE" ] }, "additionalModelRequestFields": { "top_k": 200 }, "additionalModelResponseFieldPaths": [ "/stop_sequence" ] }

Example response

Response for the above example.

HTTP/1.1 200 Content-type: application/json { "output": { "message": { "content": [ { "text": "<text generated by the model>" } ], "role": "assistant" } }, "additionalModelResponseFields": { "stop_sequence": "SUCCESS" }, "stopReason": "stop_sequence", "usage": { "inputTokens": 51, "outputTokens": 442, "totalTokens": 493 }, "metrics": { "latencyMs": 7944 } }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: