OpenAI ChatGPT API Client For Delphi and Lazarus

I couldn’t wait and have programmed something of my own for the meantime: Super einfacher Zugriff auf GPT-3.5 mit Lazarus bzw. Free Pascal – steinlaus

1 Like

I visited your site and it is great. Nice work. Compliments to you.

1 Like

Thank you all for your comments and involvement.

OpenAI API client for Delphi has now been updated and support the new chat completion endpoint, which in turn support the newest models.

The demos for Delphi and Lazarus were also updated, so you can test and play with it right away.

Thats really nice of you and thanks.
You have put so much hard work into your code and its a huge help.
I have had so many laughs lately. I find it very fascinating.

1 Like

Small change for Lazarus/Free Pascal. I needed to change the API key loading process. Although Free Pascal has a function GetEnvironmentVariable(); I think it works differently–at least in Linux. It may be checking the .bashrc file for the environment variable, but not sure on that. If you want to load the API key from a file, you can just use {$I API_FILE.KEY}. So the setting of the constant variable would be → const CApiKeyVar = {$I API_FILE.KEY};

Then the Result variable of the function TChatter.GetAPIKey would be → Result := CApiKeyVar;

Of course you could remove the constant and just set Result := {$I API_FILE.KEY}; directly if you wanted.

After doing this, you will see the code works fine in Lazarus or Free Pascal on any OS.

Thanks so much for updating the code!

What was the issue you found in the Linux demo? In any case, it’s only the demo. Also, if you just want to discuss specific source code issues, please file an issue directly at the repository:

The code for loading the API key didn’t work. I didn’t go into discovering why. I just made the change above. As you point out, it’s a demo and there are lots of ways to load up the API key.