Amazon Bedrock Runtime 2023-09-30
- Client: Aws\BedrockRuntime\BedrockRuntimeClient
- Service ID: bedrock-runtime
- Version: 2023-09-30
This page describes the parameters and results for the operations of the Amazon Bedrock Runtime (2023-09-30), and shows how to use the Aws\BedrockRuntime\BedrockRuntimeClient object to call the described operations. This documentation is specific to the 2023-09-30 API version of the service.
Operation Summary
Each of the following operations can be created from a client using
$client->getCommand('CommandName')
, where "CommandName" is the
name of one of the following operations. Note: a command is a value that
encapsulates an operation and the parameters used to create an HTTP request.
You can also create and send a command immediately using the magic methods
available on a client object: $client->commandName(/* parameters */)
.
You can send the command asynchronously (returning a promise) by appending the
word "Async" to the operation name: $client->commandNameAsync(/* parameters */)
.
- Converse ( array $params = [] )
- Sends messages to the specified Amazon Bedrock model.
- ConverseStream ( array $params = [] )
- Sends messages to the specified Amazon Bedrock model and returns the response in a stream.
- InvokeModel ( array $params = [] )
- Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.
- InvokeModelWithResponseStream ( array $params = [] )
- Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body.
Operations
Converse
$result = $client->converse
([/* ... */]); $promise = $client->converseAsync
([/* ... */]);
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. Should a model have unique inference parameters, you can also pass those unique parameters to the model. For more information, see Run inference in the Bedrock User Guide.
This operation requires permission for the bedrock:InvokeModel
action.
Parameter Syntax
$result = $client->converse([ 'additionalModelRequestFields' => [ ], 'additionalModelResponseFieldPaths' => ['<string>', ...], 'inferenceConfig' => [ 'maxTokens' => <integer>, 'stopSequences' => ['<string>', ...], 'temperature' => <float>, 'topP' => <float>, ], 'messages' => [ // REQUIRED [ 'content' => [ // REQUIRED [ 'image' => [ 'format' => 'png|jpeg|gif|webp', // REQUIRED 'source' => [ // REQUIRED 'bytes' => <string || resource || Psr\Http\Message\StreamInterface>, ], ], 'text' => '<string>', 'toolResult' => [ 'content' => [ // REQUIRED [ 'image' => [ 'format' => 'png|jpeg|gif|webp', // REQUIRED 'source' => [ // REQUIRED 'bytes' => <string || resource || Psr\Http\Message\StreamInterface>, ], ], 'json' => [ ], 'text' => '<string>', ], // ... ], 'status' => 'success|error', 'toolUseId' => '<string>', // REQUIRED ], 'toolUse' => [ 'input' => [ // REQUIRED ], 'name' => '<string>', // REQUIRED 'toolUseId' => '<string>', // REQUIRED ], ], // ... ], 'role' => 'user|assistant', // REQUIRED ], // ... ], 'modelId' => '<string>', // REQUIRED 'system' => [ [ 'text' => '<string>', ], // ... ], 'toolConfig' => [ 'toolChoice' => [ 'any' => [ ], 'auto' => [ ], 'tool' => [ 'name' => '<string>', // REQUIRED ], ], 'tools' => [ // REQUIRED [ 'toolSpec' => [ 'description' => '<string>', 'inputSchema' => [ // REQUIRED 'json' => [ ], ], 'name' => '<string>', // REQUIRED ], ], // ... ], ], ]);
Parameter Details
Members
- additionalModelRequestFields
-
- Type: document (null|bool|string|numeric) or an (array|associative array) whose members are all valid documents
Additional inference parameters that the model supports, beyond the base set of inference parameters that
Converse
supports in theinferenceConfig
field. For more information, see Model parameters. - additionalModelResponseFieldPaths
-
- Type: Array of strings
Additional model parameters field paths to return in the response.
Converse
returns the requested fields as a JSON Pointer object in theadditionalModelResultFields
field. The following is example JSON foradditionalModelResponseFieldPaths
.[ "/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 a400
error code. if the JSON Pointer is valid, but the requested field is not in the model response, it is ignored byConverse
. - inferenceConfig
-
- Type: InferenceConfiguration structure
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 theadditionalModelRequestFields
request field. - messages
-
- Required: Yes
- Type: Array of Message structures
The messages that you want to send to the model.
- modelId
-
- Required: Yes
- Type: string
The identifier for the model that you want to call.
The
modelId
to provide depends on the type of model that you use:-
If you use a base model, specify the model ID or its ARN. For a list of model IDs for base models, see Amazon Bedrock base model IDs (on-demand throughput) in the Amazon Bedrock User Guide.
-
If you use a provisioned model, specify the ARN of the Provisioned Throughput. For more information, see Run inference using a Provisioned Throughput in the Amazon Bedrock User Guide.
-
If you use a custom model, first purchase Provisioned Throughput for it. Then specify the ARN of the resulting provisioned model. For more information, see Use a custom model in Amazon Bedrock in the Amazon Bedrock User Guide.
- system
-
- Type: Array of SystemContentBlock structures
A system prompt to pass to the model.
- toolConfig
-
- Type: ToolConfiguration structure
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.
Result Syntax
[ 'additionalModelResponseFields' => [ ], 'metrics' => [ 'latencyMs' => <integer>, ], 'output' => [ 'message' => [ 'content' => [ [ 'image' => [ 'format' => 'png|jpeg|gif|webp', 'source' => [ 'bytes' => <string || resource || Psr\Http\Message\StreamInterface>, ], ], 'text' => '<string>', 'toolResult' => [ 'content' => [ [ 'image' => [ 'format' => 'png|jpeg|gif|webp', 'source' => [ 'bytes' => <string || resource || Psr\Http\Message\StreamInterface>, ], ], 'json' => [ ], 'text' => '<string>', ], // ... ], 'status' => 'success|error', 'toolUseId' => '<string>', ], 'toolUse' => [ 'input' => [ ], 'name' => '<string>', 'toolUseId' => '<string>', ], ], // ... ], 'role' => 'user|assistant', ], ], 'stopReason' => 'end_turn|tool_use|max_tokens|stop_sequence|content_filtered', 'usage' => [ 'inputTokens' => <integer>, 'outputTokens' => <integer>, 'totalTokens' => <integer>, ], ]
Result Details
Members
- additionalModelResponseFields
-
- Type: document (null|bool|string|numeric) or an (array|associative array) whose members are all valid documents
Additional fields in the response that are unique to the model.
- metrics
-
- Required: Yes
- Type: ConverseMetrics structure
Metrics for the call to
Converse
. - output
-
- Required: Yes
- Type: ConverseOutput structure
The result from the call to
Converse
. - stopReason
-
- Required: Yes
- Type: string
The reason why the model stopped generating output.
- usage
-
- Required: Yes
- Type: TokenUsage structure
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.
Errors
-
AccessDeniedException:
The request is denied because of missing access permissions.
-
ResourceNotFoundException:
The specified resource ARN was not found. Check the ARN and try your request again.
-
ThrottlingException:
The number of requests exceeds the limit. Resubmit your request later.
-
ModelTimeoutException:
The request took too long to process. Processing time exceeded the model timeout length.
-
InternalServerException:
An internal server error occurred. Retry your request.
-
ValidationException:
Input validation failed. Check your request parameters and retry the request.
-
ModelNotReadyException:
The model specified in the request is not ready to serve inference requests.
-
ModelErrorException:
The request failed due to an error while processing the model.
ConverseStream
$result = $client->converseStream
([/* ... */]); $promise = $client->converseStreamAsync
([/* ... */]);
Sends messages to the specified Amazon Bedrock model and returns the response in a stream. ConverseStream
provides a consistent API that works with all Amazon Bedrock models that support messages. This allows you to write code once and use it with different models. Should a model have unique inference parameters, you can also pass those unique parameters to the model. For more information, see Run inference in the Bedrock User Guide.
To find out if a model supports streaming, call GetFoundationModel and check the responseStreamingSupported
field in the response.
For example code, see Invoke model with streaming code example in the Amazon Bedrock User Guide.
This operation requires permission for the bedrock:InvokeModelWithResponseStream
action.
Parameter Syntax
$result = $client->converseStream([ 'additionalModelRequestFields' => [ ], 'additionalModelResponseFieldPaths' => ['<string>', ...], 'inferenceConfig' => [ 'maxTokens' => <integer>, 'stopSequences' => ['<string>', ...], 'temperature' => <float>, 'topP' => <float>, ], 'messages' => [ // REQUIRED [ 'content' => [ // REQUIRED [ 'image' => [ 'format' => 'png|jpeg|gif|webp', // REQUIRED 'source' => [ // REQUIRED 'bytes' => <string || resource || Psr\Http\Message\StreamInterface>, ], ], 'text' => '<string>', 'toolResult' => [ 'content' => [ // REQUIRED [ 'image' => [ 'format' => 'png|jpeg|gif|webp', // REQUIRED 'source' => [ // REQUIRED 'bytes' => <string || resource || Psr\Http\Message\StreamInterface>, ], ], 'json' => [ ], 'text' => '<string>', ], // ... ], 'status' => 'success|error', 'toolUseId' => '<string>', // REQUIRED ], 'toolUse' => [ 'input' => [ // REQUIRED ], 'name' => '<string>', // REQUIRED 'toolUseId' => '<string>', // REQUIRED ], ], // ... ], 'role' => 'user|assistant', // REQUIRED ], // ... ], 'modelId' => '<string>', // REQUIRED 'system' => [ [ 'text' => '<string>', ], // ... ], 'toolConfig' => [ 'toolChoice' => [ 'any' => [ ], 'auto' => [ ], 'tool' => [ 'name' => '<string>', // REQUIRED ], ], 'tools' => [ // REQUIRED [ 'toolSpec' => [ 'description' => '<string>', 'inputSchema' => [ // REQUIRED 'json' => [ ], ], 'name' => '<string>', // REQUIRED ], ], // ... ], ], ]);
Parameter Details
Members
- additionalModelRequestFields
-
- Type: document (null|bool|string|numeric) or an (array|associative array) whose members are all valid documents
Additional inference parameters that the model supports, beyond the base set of inference parameters that
ConverseStream
supports in theinferenceConfig
field. - additionalModelResponseFieldPaths
-
- Type: Array of strings
Additional model parameters field paths to return in the response.
ConverseStream
returns the requested fields as a JSON Pointer object in theadditionalModelResultFields
field. The following is example JSON foradditionalModelResponseFieldPaths
.[ "/stop_sequence" ]
For information about the JSON Pointer syntax, see the Internet Engineering Task Force (IETF) documentation.
ConverseStream
rejects an empty JSON Pointer or incorrectly structured JSON Pointer with a400
error code. if the JSON Pointer is valid, but the requested field is not in the model response, it is ignored byConverseStream
. - inferenceConfig
-
- Type: InferenceConfiguration structure
Inference parameters to pass to the model.
ConverseStream
supports a base set of inference parameters. If you need to pass additional parameters that the model supports, use theadditionalModelRequestFields
request field. - messages
-
- Required: Yes
- Type: Array of Message structures
The messages that you want to send to the model.
- modelId
-
- Required: Yes
- Type: string
The ID for the model.
The
modelId
to provide depends on the type of model that you use:-
If you use a base model, specify the model ID or its ARN. For a list of model IDs for base models, see Amazon Bedrock base model IDs (on-demand throughput) in the Amazon Bedrock User Guide.
-
If you use a provisioned model, specify the ARN of the Provisioned Throughput. For more information, see Run inference using a Provisioned Throughput in the Amazon Bedrock User Guide.
-
If you use a custom model, first purchase Provisioned Throughput for it. Then specify the ARN of the resulting provisioned model. For more information, see Use a custom model in Amazon Bedrock in the Amazon Bedrock User Guide.
- system
-
- Type: Array of SystemContentBlock structures
A system prompt to send to the model.
- toolConfig
-
- Type: ToolConfiguration structure
Configuration information for the tools that the model can use when generating a response.
This field is only supported by Anthropic Claude 3 models.
Result Syntax
[ 'stream' => [ // EventParsingIterator 'contentBlockDelta' => [ 'contentBlockIndex' => <integer>, 'delta' => [ 'text' => '<string>', 'toolUse' => [ 'input' => '<string>', ], ], ], 'contentBlockStart' => [ 'contentBlockIndex' => <integer>, 'start' => [ 'toolUse' => [ 'name' => '<string>', 'toolUseId' => '<string>', ], ], ], 'contentBlockStop' => [ 'contentBlockIndex' => <integer>, ], 'internalServerException' => [ 'message' => '<string>', ], 'messageStart' => [ 'role' => 'user|assistant', ], 'messageStop' => [ 'additionalModelResponseFields' => [ ], 'stopReason' => 'end_turn|tool_use|max_tokens|stop_sequence|content_filtered', ], 'metadata' => [ 'metrics' => [ 'latencyMs' => <integer>, ], 'usage' => [ 'inputTokens' => <integer>, 'outputTokens' => <integer>, 'totalTokens' => <integer>, ], ], 'modelStreamErrorException' => [ 'message' => '<string>', 'originalMessage' => '<string>', 'originalStatusCode' => <integer>, ], 'throttlingException' => [ 'message' => '<string>', ], 'validationException' => [ 'message' => '<string>', ], ], ]
Result Details
Members
- stream
-
- Type: EventParsingIterator supplying the following structures: MessageStartEvent, ContentBlockStartEvent, ContentBlockDeltaEvent, ContentBlockStopEvent, MessageStopEvent, ConverseStreamMetadataEvent, InternalServerException, ModelStreamErrorException, ValidationException, ThrottlingException
The output stream that the model generated.
Using an EventParsingIterator
To use an EventParsingIterator, you will need to loop over the events it will generate and check the top-level field to determine which type of event it is.
foreach($result['stream'] as $event) { if (isset($event['contentBlockDelta'])) { // Handle the 'contentBlockDelta' event. } else if (isset($event['contentBlockStart'])) { // Handle the 'contentBlockStart' event. } else if (isset($event['contentBlockStop'])) { // Handle the 'contentBlockStop' event. } else if (isset($event['internalServerException'])) { // Handle the 'internalServerException' event. } else if (isset($event['messageStart'])) { // Handle the 'messageStart' event. } else if (isset($event['messageStop'])) { // Handle the 'messageStop' event. } else if (isset($event['metadata'])) { // Handle the 'metadata' event. } else if (isset($event['modelStreamErrorException'])) { // Handle the 'modelStreamErrorException' event. } else if (isset($event['throttlingException'])) { // Handle the 'throttlingException' event. } else if (isset($event['validationException'])) { // Handle the 'validationException' event. } }
Errors
-
AccessDeniedException:
The request is denied because of missing access permissions.
-
ResourceNotFoundException:
The specified resource ARN was not found. Check the ARN and try your request again.
-
ThrottlingException:
The number of requests exceeds the limit. Resubmit your request later.
-
ModelTimeoutException:
The request took too long to process. Processing time exceeded the model timeout length.
-
InternalServerException:
An internal server error occurred. Retry your request.
-
ValidationException:
Input validation failed. Check your request parameters and retry the request.
-
ModelNotReadyException:
The model specified in the request is not ready to serve inference requests.
-
ModelErrorException:
The request failed due to an error while processing the model.
InvokeModel
$result = $client->invokeModel
([/* ... */]); $promise = $client->invokeModelAsync
([/* ... */]);
Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. You use model inference to generate text, images, and embeddings.
For example code, see Invoke model code examples in the Amazon Bedrock User Guide.
This operation requires permission for the bedrock:InvokeModel
action.
Parameter Syntax
$result = $client->invokeModel([ 'accept' => '<string>', 'body' => <string || resource || Psr\Http\Message\StreamInterface>, // REQUIRED 'contentType' => '<string>', 'guardrailIdentifier' => '<string>', 'guardrailVersion' => '<string>', 'modelId' => '<string>', // REQUIRED 'trace' => 'ENABLED|DISABLED', ]);
Parameter Details
Members
- accept
-
- Type: string
The desired MIME type of the inference body in the response. The default value is
application/json
. - body
-
- Required: Yes
- Type: blob (string|resource|Psr\Http\Message\StreamInterface)
The prompt and inference parameters in the format specified in the
contentType
in the header. To see the format and content of the request and response bodies for different models, refer to Inference parameters. For more information, see Run inference in the Bedrock User Guide. - contentType
-
- Type: string
The MIME type of the input data in the request. The default value is
application/json
. - guardrailIdentifier
-
- Type: string
The unique identifier of the guardrail that you want to use. If you don't provide a value, no guardrail is applied to the invocation.
An error will be thrown in the following situations.
-
You don't provide a guardrail identifier but you specify the
amazon-bedrock-guardrailConfig
field in the request body. -
You enable the guardrail but the
contentType
isn'tapplication/json
. -
You provide a guardrail identifier, but
guardrailVersion
isn't specified.
- guardrailVersion
-
- Type: string
The version number for the guardrail. The value can also be
DRAFT
. - modelId
-
- Required: Yes
- Type: string
The unique identifier of the model to invoke to run inference.
The
modelId
to provide depends on the type of model that you use:-
If you use a base model, specify the model ID or its ARN. For a list of model IDs for base models, see Amazon Bedrock base model IDs (on-demand throughput) in the Amazon Bedrock User Guide.
-
If you use a provisioned model, specify the ARN of the Provisioned Throughput. For more information, see Run inference using a Provisioned Throughput in the Amazon Bedrock User Guide.
-
If you use a custom model, first purchase Provisioned Throughput for it. Then specify the ARN of the resulting provisioned model. For more information, see Use a custom model in Amazon Bedrock in the Amazon Bedrock User Guide.
- trace
-
- Type: string
Specifies whether to enable or disable the Bedrock trace. If enabled, you can see the full Bedrock trace.
Result Syntax
[ 'body' => <string || resource || Psr\Http\Message\StreamInterface>, 'contentType' => '<string>', ]
Result Details
Members
- body
-
- Required: Yes
- Type: blob (string|resource|Psr\Http\Message\StreamInterface)
Inference response from the model in the format specified in the
contentType
header. To see the format and content of the request and response bodies for different models, refer to Inference parameters. - contentType
-
- Required: Yes
- Type: string
The MIME type of the inference result.
Errors
-
AccessDeniedException:
The request is denied because of missing access permissions.
-
ResourceNotFoundException:
The specified resource ARN was not found. Check the ARN and try your request again.
-
ThrottlingException:
The number of requests exceeds the limit. Resubmit your request later.
-
ModelTimeoutException:
The request took too long to process. Processing time exceeded the model timeout length.
-
InternalServerException:
An internal server error occurred. Retry your request.
-
ValidationException:
Input validation failed. Check your request parameters and retry the request.
-
ModelNotReadyException:
The model specified in the request is not ready to serve inference requests.
-
ServiceQuotaExceededException:
The number of requests exceeds the service quota. Resubmit your request later.
-
ModelErrorException:
The request failed due to an error while processing the model.
InvokeModelWithResponseStream
$result = $client->invokeModelWithResponseStream
([/* ... */]); $promise = $client->invokeModelWithResponseStreamAsync
([/* ... */]);
Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. The response is returned in a stream.
To see if a model supports streaming, call GetFoundationModel and check the responseStreamingSupported
field in the response.
The CLI doesn't support InvokeModelWithResponseStream
.
For example code, see Invoke model with streaming code example in the Amazon Bedrock User Guide.
This operation requires permissions to perform the bedrock:InvokeModelWithResponseStream
action.
Parameter Syntax
$result = $client->invokeModelWithResponseStream([ 'accept' => '<string>', 'body' => <string || resource || Psr\Http\Message\StreamInterface>, // REQUIRED 'contentType' => '<string>', 'guardrailIdentifier' => '<string>', 'guardrailVersion' => '<string>', 'modelId' => '<string>', // REQUIRED 'trace' => 'ENABLED|DISABLED', ]);
Parameter Details
Members
- accept
-
- Type: string
The desired MIME type of the inference body in the response. The default value is
application/json
. - body
-
- Required: Yes
- Type: blob (string|resource|Psr\Http\Message\StreamInterface)
The prompt and inference parameters in the format specified in the
contentType
in the header. To see the format and content of the request and response bodies for different models, refer to Inference parameters. For more information, see Run inference in the Bedrock User Guide. - contentType
-
- Type: string
The MIME type of the input data in the request. The default value is
application/json
. - guardrailIdentifier
-
- Type: string
The unique identifier of the guardrail that you want to use. If you don't provide a value, no guardrail is applied to the invocation.
An error is thrown in the following situations.
-
You don't provide a guardrail identifier but you specify the
amazon-bedrock-guardrailConfig
field in the request body. -
You enable the guardrail but the
contentType
isn'tapplication/json
. -
You provide a guardrail identifier, but
guardrailVersion
isn't specified.
- guardrailVersion
-
- Type: string
The version number for the guardrail. The value can also be
DRAFT
. - modelId
-
- Required: Yes
- Type: string
The unique identifier of the model to invoke to run inference.
The
modelId
to provide depends on the type of model that you use:-
If you use a base model, specify the model ID or its ARN. For a list of model IDs for base models, see Amazon Bedrock base model IDs (on-demand throughput) in the Amazon Bedrock User Guide.
-
If you use a provisioned model, specify the ARN of the Provisioned Throughput. For more information, see Run inference using a Provisioned Throughput in the Amazon Bedrock User Guide.
-
If you use a custom model, first purchase Provisioned Throughput for it. Then specify the ARN of the resulting provisioned model. For more information, see Use a custom model in Amazon Bedrock in the Amazon Bedrock User Guide.
- trace
-
- Type: string
Specifies whether to enable or disable the Bedrock trace. If enabled, you can see the full Bedrock trace.
Result Syntax
[ 'body' => [ // EventParsingIterator 'chunk' => [ 'bytes' => <string || resource || Psr\Http\Message\StreamInterface>, ], 'internalServerException' => [ 'message' => '<string>', ], 'modelStreamErrorException' => [ 'message' => '<string>', 'originalMessage' => '<string>', 'originalStatusCode' => <integer>, ], 'modelTimeoutException' => [ 'message' => '<string>', ], 'throttlingException' => [ 'message' => '<string>', ], 'validationException' => [ 'message' => '<string>', ], ], 'contentType' => '<string>', ]
Result Details
Members
- body
-
- Required: Yes
- Type: EventParsingIterator supplying the following structures: PayloadPart, InternalServerException, ModelStreamErrorException, ValidationException, ThrottlingException, ModelTimeoutException
Inference response from the model in the format specified by the
contentType
header. To see the format and content of this field for different models, refer to Inference parameters. - contentType
-
- Required: Yes
- Type: string
The MIME type of the inference result.
Using an EventParsingIterator
To use an EventParsingIterator, you will need to loop over the events it will generate and check the top-level field to determine which type of event it is.
foreach($result['body'] as $event) { if (isset($event['chunk'])) { // Handle the 'chunk' event. } else if (isset($event['internalServerException'])) { // Handle the 'internalServerException' event. } else if (isset($event['modelStreamErrorException'])) { // Handle the 'modelStreamErrorException' event. } else if (isset($event['modelTimeoutException'])) { // Handle the 'modelTimeoutException' event. } else if (isset($event['throttlingException'])) { // Handle the 'throttlingException' event. } else if (isset($event['validationException'])) { // Handle the 'validationException' event. } }
Errors
-
AccessDeniedException:
The request is denied because of missing access permissions.
-
ResourceNotFoundException:
The specified resource ARN was not found. Check the ARN and try your request again.
-
ThrottlingException:
The number of requests exceeds the limit. Resubmit your request later.
-
ModelTimeoutException:
The request took too long to process. Processing time exceeded the model timeout length.
-
InternalServerException:
An internal server error occurred. Retry your request.
-
ModelStreamErrorException:
An error occurred while streaming the response. Retry your request.
-
ValidationException:
Input validation failed. Check your request parameters and retry the request.
-
ModelNotReadyException:
The model specified in the request is not ready to serve inference requests.
-
ServiceQuotaExceededException:
The number of requests exceeds the service quota. Resubmit your request later.
-
ModelErrorException:
The request failed due to an error while processing the model.
Shapes
AccessDeniedException
Description
The request is denied because of missing access permissions.
Members
- message
-
- Type: string
AnyToolChoice
Description
The model must request at least one tool (no text is generated).
Members
AutoToolChoice
Description
The Model automatically decides if a tool should be called or to whether to generate text instead.
Members
ContentBlock
Description
A block of content for a message.
Members
- image
-
- Type: ImageBlock structure
Image to include in the message.
This field is only supported by Anthropic Claude 3 models.
- text
-
- Type: string
Text to include in the message.
- toolResult
-
- Type: ToolResultBlock structure
The result for a tool request that a model makes.
- toolUse
-
- Type: ToolUseBlock structure
Information about a tool use request from a model.
ContentBlockDelta
Description
A bock of content in a streaming response.
Members
- text
-
- Type: string
The content text.
- toolUse
-
- Type: ToolUseBlockDelta structure
Information about a tool that the model is requesting to use.
ContentBlockDeltaEvent
Description
The content block delta event.
Members
- contentBlockIndex
-
- Required: Yes
- Type: int
The block index for a content block delta event.
- delta
-
- Required: Yes
- Type: ContentBlockDelta structure
The delta for a content block delta event.
ContentBlockStart
Description
Content block start information.
Members
- toolUse
-
- Type: ToolUseBlockStart structure
Information about a tool that the model is requesting to use.
ContentBlockStartEvent
Description
Content block start event.
Members
- contentBlockIndex
-
- Required: Yes
- Type: int
The index for a content block start event.
- start
-
- Required: Yes
- Type: ContentBlockStart structure
Start information about a content block start event.
ContentBlockStopEvent
Description
A content block stop event.
Members
- contentBlockIndex
-
- Required: Yes
- Type: int
The index for a content block.
ConverseMetrics
Description
Metrics for a call to Converse.
Members
- latencyMs
-
- Required: Yes
- Type: long (int|float)
The latency of the call to
Converse
, in milliseconds.
ConverseOutput
ConverseStreamMetadataEvent
Description
A conversation stream metadata event.
Members
- metrics
-
- Required: Yes
- Type: ConverseStreamMetrics structure
The metrics for the conversation stream metadata event.
- usage
-
- Required: Yes
- Type: TokenUsage structure
Usage information for the conversation stream event.
ConverseStreamMetrics
Description
Metrics for the stream.
Members
- latencyMs
-
- Required: Yes
- Type: long (int|float)
The latency for the streaming request, in milliseconds.
ConverseStreamOutput
Description
The messages output stream
Members
- contentBlockDelta
-
- Type: ContentBlockDeltaEvent structure
The messages output content block delta.
- contentBlockStart
-
- Type: ContentBlockStartEvent structure
Start information for a content block.
- contentBlockStop
-
- Type: ContentBlockStopEvent structure
Stop information for a content block.
- internalServerException
-
- Type: InternalServerException structure
An internal server error occurred. Retry your request.
- messageStart
-
- Type: MessageStartEvent structure
Message start information.
- messageStop
-
- Type: MessageStopEvent structure
Message stop information.
- metadata
-
- Type: ConverseStreamMetadataEvent structure
Metadata for the converse output stream.
- modelStreamErrorException
-
- Type: ModelStreamErrorException structure
A streaming error occurred. Retry your request.
- throttlingException
-
- Type: ThrottlingException structure
The number of requests exceeds the limit. Resubmit your request later.
- validationException
-
- Type: ValidationException structure
Input validation failed. Check your request parameters and retry the request.
Document
Members
ImageBlock
Description
Image content for a message.
Members
- format
-
- Required: Yes
- Type: string
The format of the image.
- source
-
- Required: Yes
- Type: ImageSource structure
The source for the image.
ImageSource
Description
The source for an image.
Members
- bytes
-
- Type: blob (string|resource|Psr\Http\Message\StreamInterface)
The raw image bytes for the image. If you use an AWS SDK, you don't need to base64 encode the image bytes.
InferenceConfiguration
Description
Base inference parameters to pass to a model in a call to Converse or ConverseStream. For more information, see Inference parameters for foundation models.
If you need to pass additional parameters that the model supports, use the additionalModelRequestFields
request field in the call to Converse
or ConverseStream
. For more information, see Model parameters.
Members
- maxTokens
-
- Type: int
The maximum number of tokens to allow in the generated response. The default value is the maximum allowed value for the model that you are using. For more information, see Inference parameters for foundatio{ "messages": [ { "role": "user", "content": [ { "text": "what's the weather in Queens, NY and Austin, TX?" } ] }, { "role": "assistant", "content": [ { "toolUse": { "toolUseId": "1", "name": "get_weather", "input": { "city": "Queens", "state": "NY" } } }, { "toolUse": { "toolUseId": "2", "name": "get_weather", "input": { "city": "Austin", "state": "TX" } } } ] }, { "role": "user", "content": [ { "toolResult": { "toolUseId": "2", "content": [ { "json": { "weather": "40" } } ] } }, { "text": "..." }, { "toolResult": { "toolUseId": "1", "content": [ { "text": "result text" } ] } } ] } ], "toolConfig": { "tools": [ { "name": "get_weather", "description": "Get weather", "inputSchema": { "type": "object", "properties": { "city": { "type": "string", "description": "City of location" }, "state": { "type": "string", "description": "State of location" } }, "required": ["city", "state"] } } ] } } n models.
- stopSequences
-
- Type: Array of strings
A list of stop sequences. A stop sequence is a sequence of characters that causes the model to stop generating the response.
- temperature
-
- Type: float
The likelihood of the model selecting higher-probability options while generating a response. A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options.
The default value is the default value for the model that you are using. For more information, see Inference parameters for foundation models.
- topP
-
- Type: float
The percentage of most-likely candidates that the model considers for the next token. For example, if you choose a value of 0.8 for
topP
, the model selects from the top 80% of the probability distribution of tokens that could be next in the sequence.The default value is the default value for the model that you are using. For more information, see Inference parameters for foundation models.
InternalServerException
Description
An internal server error occurred. Retry your request.
Members
- message
-
- Type: string
Message
Description
Members
- content
-
- Required: Yes
- Type: Array of ContentBlock structures
The message content.
- role
-
- Required: Yes
- Type: string
The role that the message plays in the message.
MessageStartEvent
Description
The start of a message.
Members
- role
-
- Required: Yes
- Type: string
The role for the message.
MessageStopEvent
Description
The stop event for a message.
Members
- additionalModelResponseFields
-
- Type: document (null|bool|string|numeric) or an (array|associative array) whose members are all valid documents
The additional model response fields.
- stopReason
-
- Required: Yes
- Type: string
The reason why the model stopped generating output.
ModelErrorException
Description
The request failed due to an error while processing the model.
Members
- message
-
- Type: string
- originalStatusCode
-
- Type: int
The original status code.
- resourceName
-
- Type: string
The resource name.
ModelNotReadyException
Description
The model specified in the request is not ready to serve inference requests.
Members
- message
-
- Type: string
ModelStreamErrorException
Description
An error occurred while streaming the response. Retry your request.
Members
- message
-
- Type: string
- originalMessage
-
- Type: string
The original message.
- originalStatusCode
-
- Type: int
The original status code.
ModelTimeoutException
Description
The request took too long to process. Processing time exceeded the model timeout length.
Members
- message
-
- Type: string
PayloadPart
Description
Payload content included in the response.
Members
- bytes
-
- Type: blob (string|resource|Psr\Http\Message\StreamInterface)
Base64-encoded bytes of payload data.
ResourceNotFoundException
Description
The specified resource ARN was not found. Check the ARN and try your request again.
Members
- message
-
- Type: string
ResponseStream
Description
Definition of content in the response stream.
Members
- chunk
-
- Type: PayloadPart structure
Content included in the response.
- internalServerException
-
- Type: InternalServerException structure
An internal server error occurred. Retry your request.
- modelStreamErrorException
-
- Type: ModelStreamErrorException structure
An error occurred while streaming the response. Retry your request.
- modelTimeoutException
-
- Type: ModelTimeoutException structure
The request took too long to process. Processing time exceeded the model timeout length.
- throttlingException
-
- Type: ThrottlingException structure
The number or frequency of requests exceeds the limit. Resubmit your request later.
- validationException
-
- Type: ValidationException structure
Input validation failed. Check your request parameters and retry the request.
ServiceQuotaExceededException
Description
The number of requests exceeds the service quota. Resubmit your request later.
Members
- message
-
- Type: string
SpecificToolChoice
Description
The model must request a specific tool.
This field is only supported by Anthropic Claude 3 models.
Members
- name
-
- Required: Yes
- Type: string
The name of the tool that the model must request.
SystemContentBlock
Description
A system content block
Members
- text
-
- Type: string
A system prompt for the model.
ThrottlingException
Description
The number of requests exceeds the limit. Resubmit your request later.
Members
- message
-
- Type: string
TokenUsage
Description
The tokens used in a message API inference call.
Members
- inputTokens
-
- Required: Yes
- Type: int
The number of tokens sent in the request to the model.
- outputTokens
-
- Required: Yes
- Type: int
The number of tokens that the model generated for the request.
- totalTokens
-
- Required: Yes
- Type: int
The total of input tokens and tokens generated by the model.
Tool
Description
Information about a tool that you can use with the Converse API.
Members
- toolSpec
-
- Type: ToolSpecification structure
The specfication for the tool.
ToolChoice
Description
Forces a model to use a tool.
Members
- any
-
- Type: AnyToolChoice structure
The model must request at least one tool (no text is generated).
- auto
-
- Type: AutoToolChoice structure
The Model automatically decides if a tool should be called or to whether to generate text instead.
- tool
-
- Type: SpecificToolChoice structure
The Model must request the specified tool.
ToolConfiguration
Description
Configuration information for the tools that you pass to a model.
This field is only supported by Anthropic Claude 3, Cohere Command R, Cohere Command R+, and Mistral Large models.
Members
- toolChoice
-
- Type: ToolChoice structure
If supported by model, forces the model to request a tool.
- tools
-
- Required: Yes
- Type: Array of Tool structures
An array of tools that you want to pass to a model.
ToolInputSchema
Description
The schema for the tool. The top level schema type must be object
.
Members
- json
-
- Type: document (null|bool|string|numeric) or an (array|associative array) whose members are all valid documents
The JSON schema for the tool. For more information, see JSON Schema Reference.
ToolResultBlock
Description
A tool result block that contains the results for a tool request that the model previously made.
Members
- content
-
- Required: Yes
- Type: Array of ToolResultContentBlock structures
The content for tool result content block.
- status
-
- Type: string
The status for the tool result content block.
This field is only supported Anthropic Claude 3 models.
- toolUseId
-
- Required: Yes
- Type: string
The ID of the tool request that this is the result for.
ToolResultContentBlock
Description
The tool result content block.
Members
- image
-
- Type: ImageBlock structure
A tool result that is an image.
This field is only supported by Anthropic Claude 3 models.
- json
-
- Type: document (null|bool|string|numeric) or an (array|associative array) whose members are all valid documents
A tool result that is JSON format data.
- text
-
- Type: string
A tool result that is text.
ToolSpecification
Description
The specification for the tool.
Members
- description
-
- Type: string
The description for the tool.
- inputSchema
-
- Required: Yes
- Type: ToolInputSchema structure
The input schema for the tool in JSON format.
- name
-
- Required: Yes
- Type: string
The name for the tool.
ToolUseBlock
Description
A tool use content block. Contains information about a tool that the model is requesting be run., The model uses the result from the tool to generate a response.
Members
- input
-
- Required: Yes
- Type: document (null|bool|string|numeric) or an (array|associative array) whose members are all valid documents
The input to pass to the tool.
- name
-
- Required: Yes
- Type: string
The name of the tool that the model wants to use.
- toolUseId
-
- Required: Yes
- Type: string
The ID for the tool request.
ToolUseBlockDelta
Description
The delta for a tool use block.
Members
- input
-
- Required: Yes
- Type: string
The input for a requested tool.
ToolUseBlockStart
Description
The start of a tool use block.
Members
- name
-
- Required: Yes
- Type: string
The name of the tool that the model is requesting to use.
- toolUseId
-
- Required: Yes
- Type: string
The ID for the tool request.
ValidationException
Description
Input validation failed. Check your request parameters and retry the request.
Members
- message
-
- Type: string