import { Command as $Command } from "@smithy/smithy-client"; import type { BlobPayloadInputTypes, MetadataBearer as __MetadataBearer } from "@smithy/types"; import type { BedrockRuntimeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BedrockRuntimeClient"; import { type InvokeModelWithResponseStreamResponse, InvokeModelWithResponseStreamRequest } from "../models/models_0"; /** * @public */ export type { __MetadataBearer }; export { $Command }; /** * @public */ export type InvokeModelWithResponseStreamCommandInputType = Omit & { body?: BlobPayloadInputTypes; }; /** * @public * * The input for {@link InvokeModelWithResponseStreamCommand}. */ export interface InvokeModelWithResponseStreamCommandInput extends InvokeModelWithResponseStreamCommandInputType { } /** * @public * * The output of {@link InvokeModelWithResponseStreamCommand}. */ export interface InvokeModelWithResponseStreamCommandOutput extends InvokeModelWithResponseStreamResponse, __MetadataBearer { } declare const InvokeModelWithResponseStreamCommand_base: { new (input: InvokeModelWithResponseStreamCommandInput): import("@smithy/smithy-client").CommandImpl; new (input: InvokeModelWithResponseStreamCommandInput): import("@smithy/smithy-client").CommandImpl; getEndpointParameterInstructions(): import("@smithy/middleware-endpoint").EndpointParameterInstructions; }; /** *

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 streaming operations in Amazon Bedrock, including 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.

To deny all inference access to resources that you specify in the modelId field, you need to deny access to the bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream actions. Doing this also denies access to the resource through the Converse API actions (Converse and ConverseStream). For more information see Deny access for inference on specific models.

For troubleshooting some of the common errors you might encounter when using the InvokeModelWithResponseStream API, see Troubleshooting Amazon Bedrock API Error Codes in the Amazon Bedrock User Guide

* @example * Use a bare-bones client and the command you need to make an API call. * ```javascript * import { BedrockRuntimeClient, InvokeModelWithResponseStreamCommand } from "@aws-sdk/client-bedrock-runtime"; // ES Modules import * // const { BedrockRuntimeClient, InvokeModelWithResponseStreamCommand } = require("@aws-sdk/client-bedrock-runtime"); // CommonJS import * // import type { BedrockRuntimeClientConfig } from "@aws-sdk/client-bedrock-runtime"; * const config = {}; // type is BedrockRuntimeClientConfig * const client = new BedrockRuntimeClient(config); * const input = { // InvokeModelWithResponseStreamRequest * body: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") * contentType: "STRING_VALUE", * accept: "STRING_VALUE", * modelId: "STRING_VALUE", // required * trace: "ENABLED" || "DISABLED" || "ENABLED_FULL", * guardrailIdentifier: "STRING_VALUE", * guardrailVersion: "STRING_VALUE", * performanceConfigLatency: "standard" || "optimized", * serviceTier: "priority" || "default" || "flex" || "reserved", * }; * const command = new InvokeModelWithResponseStreamCommand(input); * const response = await client.send(command); * // { // InvokeModelWithResponseStreamResponse * // body: { // ResponseStream Union: only one key present * // chunk: { // PayloadPart * // bytes: new Uint8Array(), * // }, * // internalServerException: { // InternalServerException * // message: "STRING_VALUE", * // }, * // modelStreamErrorException: { // ModelStreamErrorException * // message: "STRING_VALUE", * // originalStatusCode: Number("int"), * // originalMessage: "STRING_VALUE", * // }, * // validationException: { // ValidationException * // message: "STRING_VALUE", * // }, * // throttlingException: { // ThrottlingException * // message: "STRING_VALUE", * // }, * // modelTimeoutException: { // ModelTimeoutException * // message: "STRING_VALUE", * // }, * // serviceUnavailableException: { // ServiceUnavailableException * // message: "STRING_VALUE", * // }, * // }, * // contentType: "STRING_VALUE", // required * // performanceConfigLatency: "standard" || "optimized", * // serviceTier: "priority" || "default" || "flex" || "reserved", * // }; * * ``` * * @param InvokeModelWithResponseStreamCommandInput - {@link InvokeModelWithResponseStreamCommandInput} * @returns {@link InvokeModelWithResponseStreamCommandOutput} * @see {@link InvokeModelWithResponseStreamCommandInput} for command's `input` shape. * @see {@link InvokeModelWithResponseStreamCommandOutput} for command's `response` shape. * @see {@link BedrockRuntimeClientResolvedConfig | config} for BedrockRuntimeClient's `config` shape. * * @throws {@link AccessDeniedException} (client fault) *

The request is denied because you do not have sufficient permissions to perform the requested action. For troubleshooting this error, see AccessDeniedException in the Amazon Bedrock User Guide

* * @throws {@link InternalServerException} (server fault) *

An internal server error occurred. For troubleshooting this error, see InternalFailure in the Amazon Bedrock User Guide

* * @throws {@link ModelErrorException} (client fault) *

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

* * @throws {@link ModelNotReadyException} (client fault) *

The model specified in the request is not ready to serve inference requests. The AWS SDK will automatically retry the operation up to 5 times. For information about configuring automatic retries, see Retry behavior in the AWS SDKs and Tools reference guide.

* * @throws {@link ModelStreamErrorException} (client fault) *

An error occurred while streaming the response. Retry your request.

* * @throws {@link ModelTimeoutException} (client fault) *

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

* * @throws {@link ResourceNotFoundException} (client fault) *

The specified resource ARN was not found. For troubleshooting this error, see ResourceNotFound in the Amazon Bedrock User Guide

* * @throws {@link ServiceQuotaExceededException} (client fault) *

Your request exceeds the service quota for your account. You can view your quotas at Viewing service quotas. You can resubmit your request later.

* * @throws {@link ServiceUnavailableException} (server fault) *

The service isn't currently available. For troubleshooting this error, see ServiceUnavailable in the Amazon Bedrock User Guide

* * @throws {@link ThrottlingException} (client fault) *

Your request was denied due to exceeding the account quotas for Amazon Bedrock. For troubleshooting this error, see ThrottlingException in the Amazon Bedrock User Guide

* * @throws {@link ValidationException} (client fault) *

The input fails to satisfy the constraints specified by Amazon Bedrock. For troubleshooting this error, see ValidationError in the Amazon Bedrock User Guide

* * @throws {@link BedrockRuntimeServiceException} *

Base exception class for all service exceptions from BedrockRuntime service.

* * * @public */ export declare class InvokeModelWithResponseStreamCommand extends InvokeModelWithResponseStreamCommand_base { /** @internal type navigation helper, not in runtime. */ protected static __types: { api: { input: InvokeModelWithResponseStreamRequest; output: InvokeModelWithResponseStreamResponse; }; sdk: { input: InvokeModelWithResponseStreamCommandInput; output: InvokeModelWithResponseStreamCommandOutput; }; }; }