Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy support #263

Open
ovchinnikovndre1 opened this issue Nov 16, 2023 · 5 comments
Open

Add proxy support #263

ovchinnikovndre1 opened this issue Nov 16, 2023 · 5 comments

Comments

@ovchinnikovndre1
Copy link

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

@gehrisandro
Copy link
Collaborator

@ovchinnikovndre1 Please provide more information. At least the exception message and stack trace.

@fishfree
Copy link

fishfree commented Nov 23, 2023

+1 pls
Sometimes we need set HTTP/SOCKS5 proxy to access api.openai.com

@ebudmada
Copy link

ebudmada commented Dec 1, 2023

yes this feature would be useful

@yarooze
Copy link

yarooze commented Dec 27, 2023

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();

@iPabro
Copy link

iPabro commented Apr 9, 2024

For socks5 working like this

$client = \OpenAI::factory()
        ->withApiKey($apiKey)
        ->withHttpClient($client = new \GuzzleHttp\Client([
            'proxy' => 'socks5://USER:PASSWORD@ip:port'
        ]))
        ->make();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants