openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.56k stars 466 forks source link

Constant HTTP 500 Server errors #356

Closed wolfhuntme closed 1 month ago

wolfhuntme commented 3 months ago

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?

wolfhuntme commented 3 months ago

I'm using php 8.1.2 cli ubuntu if that matters.

PeperMarkreel commented 3 months ago

Check the apache error log file, it will show you what is going wrong.

gehrisandro commented 1 month ago

Hi @wolfhuntme

This does not look like an error related to the package.

If you do not agree, feel free to reopen the issue.