ApiBaseStreamAsyncTRequest, TResponse Method

Streams responses by sending an HTTP request with a JSON payload and yielding the deserialized items as they arrive.

Definition

Namespace: GenerativeAI.Core
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
protected IAsyncEnumerable<TResponse> StreamAsync<TRequest, TResponse>(
	string url,
	TRequest payload,
	CancellationToken cancellationToken = default
)

Parameters

url  String
The target endpoint URL to which the request is sent.
payload  TRequest
The request payload.
cancellationToken  CancellationToken  (Optional)
A token for cancelling the operation.

Type Parameters

TRequest
The type of the request payload to serialize.
TResponse
The type of the response items to deserialize.

Return Value

IAsyncEnumerableTResponse
An async stream of response items.

See Also