Integrate browser_ai_ckeditor into Drupal AI module : Allow calling AI Apis on browser
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3560964. --> Reported by: [saitanay](https://www.drupal.org/user/220136) >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>There is an identified use case for executing AI operations that requires calling APIs directly in the browser from backend code. currently, the Drupal AI module primarily focuses on server-side integration.</p> <p>As noted in discussions, to support this usecase properly, the AI module's abstraction layer needs to accommodate scenarios where the execution happens on the client side but is orchestrated or initiated by the backend.</p> <p><strong><a href="https://www.drupal.org/project/browser_ai_ckeditor">https://www.drupal.org/project/browser_ai_ckeditor</a></strong></p> <p>The main technical hurdle is that the backend code cannot currently easily instruct the browser to call specific APIs or execute client-side AI tasks without a persistent connection or a specific bridge mechanism.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Attempt to implement an AI workflow where the model execution or API call must happen in the user's browser (client-side) rather than the server.</p> <p>Try to trigger this browser-side event directly from a standard Drupal backend hook or event subscriber within the current AI module architecture.</p> <p>Observation: There is no standard mechanism in the abstraction layer to "push" this request to the browser or handle the bidirectional communication required to get the result back to Drupal.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Update the Drupal AI module's abstraction layer to support browser-based execution targets.</p> <p>Specific technical approaches to investigate include:</p> <p>Web Socket Integration: Implementing a WebSocket connection to allow the Drupal backend to push instructions to the browser in real-time.</p> <p>Abstraction Layer Expansion: Refactor the current provider/explorer architecture to distinguish between ServerSide and BrowserSide execution implementation.</p> <p>API Bridging: Create a standard method for the backend to queue or trigger browser API calls (potentially via AJAX polling if WebSockets are too heavy).</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>[ ] Investigate the feasibility of adding a WebSocket requirement or submodule to the AI module.</p> <p>[ ] Define the interface for "Browser-based" AI providers in the abstraction layer.</p> <p>[ ] Create a proof-of-concept where a backend event triggers a browser console log or simple fetch via the proposed connection method.</p> <h3 id="summary-ui-changes">User interface changes</h3> <p>Likely minimal.</p> <p>Potential addition of configuration forms for WebSocket server settings or client-side API keys if necessary.</p> <h3 id="summary-api-changes">API changes</h3> <p>Additions to the AI Module abstraction layer interfaces to support client_side execution capability.</p> <p>New services or plugins to handle the backend-to-browser communication pipeline.</p> <h3 id="summary-data-model-changes">Data model changes</h3> <p>No database schema changes are currently anticipated, though configuration schema updates will be required to store settings for the new integration layer.</p> > Related issue: [Issue #3560963](https://www.drupal.org/node/3560963)
issue