Hello I am new to Lazarus as well as programming but I would also be very interested to accomplish this.

I have managed to connect to the API with the cURL method and get a response.
However, I always get this error message.
{," ""error"": {"," ""message"": ""We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to support@openai.com and include any relevant code you'd like help with.)"","," ""type"": ""invalid_request_error"","," ""param"": null,"," ""code"": null"," }",
This is the code I used:
uses
SysUtils, Classes, Process;
var
url: string;
AStringList : TStringList;
Aprocess: TProcess;
begin
AProcess := TProcess.Create(nil);
url:='https://api.openai.com/v1/completions';
AProcess.Executable:='curl';
//AProcess.Parameters.Add('-X POST');
AProcess.Parameters.Add(url);
AProcess.Parameters.Add('-H "Authorization: Bearer API-KEY"');
AProcess.Parameters.Add('-H "Content-Type: application/json"');
AProcess.Parameters.Add('-d ''{"model": "text-davinci-003", "prompt": "Say this is a test", "temperature": 0, "max_tokens": 7}''');
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
AProcess.Execute;
AStringList := TStringList.Create;
AStringList.LoadFromStream(AProcess.Output);
Label1.Caption:= AStringList.CommaText;
end;
Here the question is embedded and the answer will be output in Label1.
(I also asked Chatt-GPT for a possible solution to the problem, it decided to insert the excluded line, but with this I got "Error 400 bad". But maybe it would be the right approach...)
Maybe this will bring you a little further
I would be happy if we could solve the problem.
Happy holidays