Skip to content

Lambda  >  Operations  >  invoke_with_response_stream

invoke_with_response_stream

Operation

invoke_with_response_stream async

invoke_with_response_stream(input: InvokeWithResponseStreamInput, plugins: list[Plugin] | None = None) -> OutputEventStream[InvokeWithResponseStreamResponseEvent, InvokeWithResponseStreamOutput]

Configure your Lambda functions to stream response payloads back to clients. For more information, see Configuring a Lambda function to stream responses.

This operation requires permission for the lambda:InvokeFunction action. For details on how to set up permissions for cross-account invocations, see Granting function access to other accounts.

Parameters:

Name Type Description Default
input InvokeWithResponseStreamInput

An instance of InvokeWithResponseStreamInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
OutputEventStream[InvokeWithResponseStreamResponseEvent, InvokeWithResponseStreamOutput]

An OutputEventStream for server-to-client streaming.

Input

InvokeWithResponseStreamInput dataclass

Dataclass for InvokeWithResponseStreamInput structure.

Attributes

client_context class-attribute instance-attribute
client_context: str | None = None

Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object.

function_name class-attribute instance-attribute
function_name: str | None = None

The name or ARN of the Lambda function.

Name formats

  • Function name -- my-function.

  • Function ARN -- arn:aws:lambda:us-west-2:123456789012:function:my-function.

  • Partial ARN -- 123456789012:function:my-function.

The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

invocation_type class-attribute instance-attribute
invocation_type: ResponseStreamingInvocationType | None = None

Use one of the following options:

  • RequestResponse (default) -- Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API operation response includes the function response and additional data.

  • DryRun -- Validate parameter values and verify that the IAM user or role has permission to invoke the function.

log_type class-attribute instance-attribute
log_type: LogType | None = None

Set to Tail to include the execution log in the response. Applies to synchronously invoked functions only.

payload class-attribute instance-attribute
payload: bytes | None = field(repr=False, default=None)

The JSON that you want to provide to your Lambda function as input.

You can enter the JSON directly. For example, --payload '{ "key": "value" }'. You can also specify a file path. For example, --payload file://payload.json.

qualifier class-attribute instance-attribute
qualifier: str | None = None

The alias name.

tenant_id class-attribute instance-attribute
tenant_id: str | None = None

The identifier of the tenant in a multi-tenant Lambda function.

Output

This operation returns an OutputEventStream for server-to-client streaming.

Event Stream Structure

Output Event Type

InvokeWithResponseStreamResponseEvent

Initial Response Structure

InvokeWithResponseStreamOutput dataclass

Dataclass for InvokeWithResponseStreamOutput structure.

Attributes
executed_version class-attribute instance-attribute
executed_version: str | None = None

The version of the function that executed. When you invoke a function with an alias, this indicates which version the alias resolved to.

response_stream_content_type class-attribute instance-attribute
response_stream_content_type: str | None = None

The type of data the stream is returning.

status_code class-attribute instance-attribute
status_code: int = 0

For a successful request, the HTTP status code is in the 200 range. For the RequestResponse invocation type, this status code is 200. For the DryRun invocation type, this status code is 204.