Translating large jobs via the ai provider often fails: allow configurable HTTP client timeout
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3547635. -->
Reported by: [doxigo](https://www.drupal.org/user/1331334)
Related to !914 !1207
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Translating large <code>TMGMT</code> jobs or even <code>ai_translate</code> via the ai provider often fails with<br>
</p><blockquote>cURL error 28: Operation timed out after 60003 milliseconds</blockquote>
<p> because the base HTTP client in <code>AiProviderClientBase</code> hardcodes a <code>60s</code> timeout.</p>
<pre>ResponseText: The website encountered an unexpected error. Try again later.Drupal\ai\Exception\AiRequestErrorException: Error invoking model response: cURL error 28: Operation timed out after 6000 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.openai.com/v1/chat/completions in Drupal\ai\Plugin\ProviderProxy->wrapperCall() (line 309 of modules/contrib/ai/src/Plugin/ProviderProxy.php). Drupal\ai\Plugin\ProviderProxy->__call() (Line: 279)</pre><p>This aborts AJAX batch calls and interrupts translations that legitimately need more time (e.g., multi-field jobs, slow upstream responses).</p>
<h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4>
<p>Configure an AI provider (e.g., OpenAI) and set up an <code>ai_tmgmt</code> translator or any other translation provider for that matter.<br>
Create a translation job with several long HTML fields, the more complex markup the better for testing.<br>
Run the job via the UI, allowing the batch process to operate for more than 60s.<br>
Observe that the batch request fails with <code>HTTP 500 / AiRequestErrorException</code> referencing cURL error 28.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Introduce a configurable timeout so site owners can raise the limit (or disable it) without patching core code or overriding it in the <code>settings.php</code> would be nice. Considering this type of work really depends on the model as well (meaning some models might take a long time to respond, eg, thinking models)</p>
issue