IGenerativeModelGenerateObjectAsyncT(String, CancellationToken) Method

Generates content asynchronously using JSON mode based on the specified text input prompt and converts the resulting JSON into a C# object of type T.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
Task<T> GenerateObjectAsync<T>(
	string prompt,
	CancellationToken cancellationToken = default
)
where T : class

Parameters

prompt  String
The text input used to generate the content.
cancellationToken  CancellationToken  (Optional)
Token to monitor for cancellation requests.

Type Parameters

T
The type of C# object to convert the resulting JSON into.

Return Value

TaskT
A task representing the asynchronous operation, containing the generated object of type T.

Remarks

Some of the complex data types are not supported such as Dictionary. So make sure to avoid these.

See Also