Closed wolfhuntme closed 1 month ago
I'm using php 8.1.2 cli ubuntu if that matters.
Check the apache error log file, it will show you what is going wrong.
Hi @wolfhuntme
This does not look like an error related to the package.
If you do not agree, feel free to reopen the issue.
Hey guys, I’ve been trying to implement the OpenAI PHP client into my PHP web server and I really don’t know what i’m doing wrong.
API KEY created in environment variable Depedencies are all installed on the server hosting the site. When I go to the site, it still pronmpts HTTP500 error
CODE BELOW:
<?php $yourApiKey = getenv('YOUR_API_KEY'); $client = OpenAI::client($yourApiKey); $result = $client->chat()->create([ 'model' => 'gpt-4', 'messages' => [ ['role' => 'user', 'content' => 'Hello!'], ], ]); echo $result->choices[0]->message->content; // Hello! How can I assist you today?