StructuredOutputs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
using var api = GetAuthenticatedClient();

MathReasoning? mathReasoning = await api.Chat.CreateChatCompletionAsAsync<MathReasoning>(
    messages: ["How can I solve 8x + 7 = -23?"],
    model: CreateChatCompletionRequestModel.Gpt4o20240806,
    strict: true);

Console.WriteLine($"Final answer: {mathReasoning?.FinalAnswer}");
Console.WriteLine("Reasoning steps:");

foreach (MathReasoningStep step in mathReasoning?.Steps ?? [])
{
    Console.WriteLine($"  - Explanation: {step.Explanation}");
    Console.WriteLine($"    Output: {step.Output}");
}