openai-php / client

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

Fatal error: Uncaught SymfonyComponentHttpClientExceptionTimeoutException: Idle timeout reached for "https://api.openai.com/v1/chat/completions". #153

Closed cmeltt closed 1 year ago

cmeltt commented 1 year ago

Hi, I have this error Fatal error: Uncaught SymfonyComponentHttpClientExceptionTimeoutException: Idle timeout reached for "https://api.openai.com/v1/chat/completions".

The solution is to use this code

`use Symfony\Component\HttpClient\HttpClient;

$client = HttpClient::create(['timeout' => 60]); // Set timeout to 60 seconds`

But I dont know where to place it. I m using symphony...

Thanks for the help !

AngadSethi commented 1 year ago

@cmeltt, try doing this:

use Symfony\Component\HttpClient\HttpClient;

$client = OpenAI::factory()->withApiKey($apiKey)->withClient(HttpClient::create([ 'timeout' => 60 ]));