client
client copied to clipboard
Add proxy support
Hi. How do I add proxy support? I tried it like this : $proxies = [ 'http' => 'http://login:pass@ip:port', ];
$client = new Client([
RequestOptions::PROXY => $proxies,
RequestOptions::VERIFY => false,
RequestOptions::TIMEOUT => 30,
]);
$this->client = OpenAI::factory()
->withApiKey(config('openai.api_key'))
->withHttpClient($client)
->make();
But I still get 500 error /var/www/vendor/openai-php/client/src/Resources/Chat.php ", line: 32
@ovchinnikovndre1 Please provide more information. At least the exception message and stack trace.
+1 pls Sometimes we need set HTTP/SOCKS5 proxy to access api.openai.com
yes this feature would be useful
Hi. How do I add proxy support? I tried it like this : $proxies = [ 'http' => 'http://login:pass@ip:port', ];
This works for me:
$client = \OpenAI::factory()
->withApiKey($apiKey)
->withHttpClient($client = new \GuzzleHttp\Client([
'proxy' => 'http://my.proxy.url:80',
]))
->make();
For socks5 working like this
$client = \OpenAI::factory()
->withApiKey($apiKey)
->withHttpClient($client = new \GuzzleHttp\Client([
'proxy' => 'socks5://USER:PASSWORD@ip:port'
]))
->make();