BaseModelGenerateContentStreamAsync Method

Streams model responses chunk by chunk given an input GenerateContentRequest.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
protected virtual IAsyncEnumerable<GenerateContentResponse> GenerateContentStreamAsync(
	string model,
	GenerateContentRequest request,
	CancellationToken cancellationToken = default
)

Parameters

model  String
The name of the Generative AI Model to use for generating the completion. Format: "models/{model}".
request  GenerateContentRequest
The GenerateContentRequest containing content of the current conversation with the model.
cancellationToken  CancellationToken  (Optional)
Token for cancelling the streaming process.

Return Value

IAsyncEnumerableGenerateContentResponse
An async stream of GenerateContentResponse items.

See Also