---
title: "POST /model/{modelId}/invoke-with-response-stream"
method: POST
path: "/model/{modelId}/invoke-with-response-stream"
---

# POST /model/{modelId}/invoke-with-response-stream

`POST /model/{modelId}/invoke-with-response-stream`

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](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GetFoundationModel.html) 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](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) and [ConverseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html)). For more information see [Deny access for inference on specific models](https://docs.aws.amazon.com/bedrock/latest/userguide/security_iam_id-based-policy-examples.html#security_iam_id-based-policy-examples-deny-inference).

For troubleshooting some of the common errors you might encounter when using the `InvokeModelWithResponseStream` API, see [Troubleshooting Amazon Bedrock API Error Codes](https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html) in the Amazon Bedrock User Guide

## Path parameters

- `modelId` string, required

## Headers

- `Content-Type` string
- `X-Amzn-Bedrock-Accept` string
- `X-Amzn-Bedrock-Trace` 'ENABLED' | 'DISABLED' | 'ENABLED_FULL'
- `X-Amzn-Bedrock-GuardrailIdentifier` string
- `X-Amzn-Bedrock-GuardrailVersion` string
- `X-Amzn-Bedrock-PerformanceConfig-Latency` 'standard' | 'optimized'
- `X-Amzn-Bedrock-Service-Tier` 'priority' | 'default' | 'flex' | 'reserved'
- `X-Amzn-Bedrock-Request-Metadata` string, password

## Request body

- object
  - `body` string, password — The prompt and inference parameters in the format specified in the <code>contentType</code> in the header. You must provide the body in JSON format. To see the format and content of the request and response bodies for different models, refer to <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html">Inference parameters</a>. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html">Run inference</a> in the Bedrock User Guide.

## Response `200`

Success

- InvokeModelWithResponseStreamResponse
  - `body` object, required — Inference response from the model in the format specified by the <code>contentType</code> header. To see the format and content of this field for different models, refer to <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html">Inference parameters</a>.
    - `chunk` object — Content included in the response.
      - `bytes` string, password — Base64-encoded bytes of payload data.
    - `internalServerException` object — An internal server error occurred. Retry your request.
      - `message` string
    - `modelStreamErrorException` object — An error occurred while streaming the response. Retry your request.
      - `message` string
      - `originalStatusCode` integer — The original status code.
      - `originalMessage` string — The original message.
    - `validationException` object — Input validation failed. Check your request parameters and retry the request.
      - `message` string
    - `throttlingException` object — Your request was throttled because of service-wide limitations. Resubmit your request later or in a different region. You can also purchase <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/prov-throughput.html">Provisioned Throughput</a> to increase the rate or number of tokens you can process.
      - `message` string
    - `modelTimeoutException` object — The request took too long to process. Processing time exceeded the model timeout length.
      - `message` string
    - `serviceUnavailableException` object — The service isn't available. Try again later.
      - `message` string

## Other responses

- `480` — AccessDeniedException
- `481` — ResourceNotFoundException
- `482` — ThrottlingException
- `483` — ModelTimeoutException
- `484` — InternalServerException
- `485` — ServiceUnavailableException
- `486` — ModelStreamErrorException
- `487` — ValidationException
- `488` — ServiceQuotaExceededException
- `489` — ModelNotReadyException
- `490` — ModelErrorException

---

[API](https://skmtc.net/aws/apis/bedrock-runtime.md) · [All operations](https://skmtc.net/aws/apis/bedrock-runtime/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aws/bedrock-runtime/revisions/8a393198b636/schema)
