How to configure custom HttpClient
```php
protected function provider(): AIProviderInterface
{
$client = new \NeuronAI\HttpClient\GuzzleHttpClient([
'timeout' => 60,
RequestOptions::VERIFY => false // 禁用 SSL 证书验证
]);
// return an instance of Anthropic, OpenAI, Gemini, Ollama, etc...
// https://docs.neuron-ai.dev/providers/ai-provider
return new Deepseek(
key: env('DEEPSEEK.API_KEY', 'DEEPSEEK_KEY'),
model: env('DEEPSEEK.MODEL', 'deepseek-chat'),
httpClient: $client
);
}
```
I configured HttpClient based on the above content, but the code did not take effect when running, so I can only modify it in the following file
\neuron-core\neuron-ai\src\HttpClient\GuzzleHttpClient.php
```php
public function request(HttpRequest $request): HttpResponse
{
$client = $this->createClient();
try {
$options = [
RequestOptions::HEADERS => [...$this->customHeaders, ...$request->headers],
RequestOptions::TIMEOUT => $this->timeout,
RequestOptions::CONNECT_TIMEOUT => $this->connectTimeout,
RequestOptions::VERIFY => false,
$response = $this->runRequest($request, $options, $client);
return new HttpResponse(
statusCode: $response->getStatusCode(),
body: $response->getBody()->getContents(),
headers: $response->getHeaders(),
);
} catch (GuzzleException $e) {
throw HttpException::networkError($request, $e);
}
}
```
adds RequestOptions::VERIFY => false
How to configure custom HttpClient and customize header more easily in provider()
关闭于 2026-04-20 2 条评论