IGenerativeModelGenerateContentAsyncT(GenerateContentRequest, CancellationToken) Method
Generates content asynchronously using JSON mode based on the given input parameters and converts the resulting JSON into a C# object of type T.
Namespace: GenerativeAIAssembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
Task<GenerateContentResponse> GenerateContentAsync<T>(
GenerateContentRequest request,
CancellationToken cancellationToken = default
)
where T : class
- request GenerateContentRequest
- An instance of GenerateContentRequest containing the input configuration and settings for content generation.
- cancellationToken CancellationToken (Optional)
- Token to monitor for cancellation requests.
- T
- The type of C# object to send as JSON schema input in request.
TaskGenerateContentResponseA task that represents the asynchronous operation, containing the generated content response of type
T.
Some of the complex data types are not supported such as Dictionary. So make sure to avoid these.