ai_ckeditor: streamGenerateContent causes 400 Bad Request with Gemini 2.x models
**Problem / Motivation** `AiRequest.php` calls `setStreamedOutput(TRUE)` for all providers. The PHP client `gemini-api-php` sends a malformed request body when calling `streamGenerateContent` against Gemini 2.x models, resulting in `400 Bad Request`. The non-streaming endpoint `generateContent` works correctly with the same payload. The error in logs: `Error invoking model response: Client error: POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent resulted in a 400 Bad Request response` Confirmed: the identical payload sent to `generateContent` (non-streaming) returns a valid response. --- **Steps to reproduce** 1. Install `drupal/ai` with submodule `ai_ckeditor` and `drupal/gemini_provider` 2. Configure Gemini 2.x model as the provider for CKEditor 3. Use any AI action inside CKEditor (Reformat HTML, etc.) 4. Observe `400 Bad Request` in Drupal logs --- **Proposed fix** Short term — disable streaming in `AiRequest.php` until the `gemini-api-php` client fixes streaming support for Gemini 2.x: ``` // In ai_ckeditor/src/AiRequest.php // Change: $messages->setStreamedOutput(TRUE); // To: $messages->setStreamedOutput(FALSE); ``` Long term — make streaming opt-in per provider, or detect provider capabilities before enabling streaming: ``` // Example of provider-aware streaming: $supportsStreaming = method_exists($ai_provider, 'supportsStreaming') && $ai_provider->supportsStreaming(); $messages->setStreamedOutput($supportsStreaming); ``` This would allow providers that handle streaming correctly (OpenAI, Anthropic) to continue using it, while Gemini falls back to non-streaming until the underlying client is fixed. --- **Environment** * `drupal/ai`: 1.4.x * `drupal/gemini_provider`: 1.0.1 * `drupal/ai_ckeditor`: included in `drupal/ai` * Models affected: `gemini-2.0-flash`, `gemini-2.0-flash-lite`, `gemini-2.5-flash`
issue