C# console app is not able to write chat completion result to console window

I’m using below code to start with open ai basics but however in console output its throwing an error, exited with code 0. In key variable i’ve stored actual api key

OpenAIClient client = new OpenAIClient(key);
ChatClient chat = client.GetChatClient(“gpt-4o-mini”);
var result = await chat.CompleteChatAsync(“Tell me about india?”);

NewMethod(result);

static void NewMethod(ClientResult result)
{
Console.WriteLine(result.Value);
}

console output-
OpenAI.Chat.ChatCompletion

C:\Users\Amol\source\repos\AI POC\AI POC\bin\Debug\net8.0\AI POC.exe (process 26444) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

1 Like