Page cover

OpenAIClient (Chat GPT)

In this super simple example, we'll create and submit a request to gpt-5.1, in only a few lines of code.

//Declare a client
var aic = new OpenAIClient(apiKey);

//Get a response
var response = await aic.GetResponseAsync(
   OpenAIClient.GPT51("It's this easy to message AI??")
   .WithInstructions("You're a helpful assistant, respond kindly and to the point"));

//Use the built in MessageContent Property to retrieve the latest message
if (response.IsSuccessful)
    Console.WriteLine(response.Data.MessageContent);

Last updated