File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 4646 */
4747
4848 'request_timeout ' => env ('OPENAI_REQUEST_TIMEOUT ' , 30 ),
49+
50+ /*
51+ |--------------------------------------------------------------------------
52+ | HTTP Handler
53+ |--------------------------------------------------------------------------
54+ |
55+ | Define a custom HTTP handler (class-string or callable) for OpenAI requests.
56+ | Useful for adding Laravel Http Events, logging, or retries via Guzzle HandlerStack.
57+ | Base Handler: OpenAI\Laravel\Http\Handler::class
58+ */
59+ 'http_handler ' => env ('OPENAI_HTTP_HANDLER ' , null ),
4960];
Original file line number Diff line number Diff line change 1111use OpenAI \Contracts \ClientContract ;
1212use OpenAI \Laravel \Commands \InstallCommand ;
1313use OpenAI \Laravel \Exceptions \ApiKeyIsMissing ;
14+ use OpenAI \Laravel \Http \Handler ;
1415
1516/**
1617 * @internal
@@ -35,7 +36,10 @@ public function register(): void
3536 $ client = OpenAI::factory ()
3637 ->withApiKey ($ apiKey )
3738 ->withOrganization ($ organization )
38- ->withHttpClient (new \GuzzleHttp \Client (['timeout ' => config ('openai.request_timeout ' , 30 )]));
39+ ->withHttpClient (new \GuzzleHttp \Client ([
40+ 'timeout ' => config ('openai.request_timeout ' , 30 ),
41+ 'handler ' => Handler::resolve (config ('openai.http_handler ' )),
42+ ]));
3943
4044 if (is_string ($ project )) {
4145 $ client ->withProject ($ project );
You can’t perform that action at this time.
0 commit comments