Share via


OpenAISerializationHelpers.SerializeAsync Method

Definition

Serializes a Microsoft.Extensions.AI response using the OpenAI wire format.

public static System.Threading.Tasks.Task SerializeAsync(System.IO.Stream stream, Microsoft.Extensions.AI.ChatResponse response, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member SerializeAsync : System.IO.Stream * Microsoft.Extensions.AI.ChatResponse * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function SerializeAsync (stream As Stream, response As ChatResponse, Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

stream
Stream

The stream to write the value.

response
ChatResponse

The chat response to serialize.

options
JsonSerializerOptions

The JsonSerializerOptions governing function call content serialization.

cancellationToken
CancellationToken

A token used to cancel the serialization operation.

Returns

A task tracking the serialization operation.

Applies to