Integrate Symfony AI's Platform component as a replacement for AI Providers
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3574187. -->
Reported by: [mxr576](https://www.drupal.org/user/315522)
Related to !1214 !1259 !1250 !1337
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>[One-line status update for stakeholders]<br>
<strong>Short Description: </strong>[One-line issue summary for stakeholders]<br>
<strong>Check-in Date: </strong>MM/DD/YYYY<br>
<em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br>
<strong>Additional Collaborators:</strong> @lussoluca, @fago<br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>
The AI module currently implements its own AI provider abstraction layer. A successful proof-of-concept (<span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-5"><a href="https://www.drupal.org/project/ai/issues/3565674" title="Status: Closed (won't fix)">#3565674: Create first version of the abstraction layer using Symfony AI v0.1.0</a></span>) demonstrated that Symfony AI's Platform component (<a href="https://symfony.com/doc/current/ai/components/platform.html">symfony/ai-platform</a>) is a viable foundation for this functionality. A kick-off call was held between @marcus_johansson, @fago, @lussoluca, @admitriiev, and @mxr576 to align on moving forward with a formal integration effort.
</p>
<p>
The Symfony AI Platform component provides a unified interface for working with various AI models and providers (OpenAI, Anthropic, Azure, Gemini, VertexAI, and more). Adopting it as the underlying abstraction in the AI module would align Drupal's AI ecosystem with a well-maintained, PHP-native standard rather than maintaining a bespoke layer. The long-term goal is for this integration to replace the current AI Provider system.
</p>
<h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4>
<p>Please provide information like AI modules enabled, which AI provider, browser, etc.</p>
<h3 id="summary-proposed-resolution">Phase 1: Analyse, PoC</h3>
<p>
The scope of this issue is to explore and evaluate different integration patterns, reach a community agreement on the best approach by weighing pros and cons, and then commit the accepted solution to the AI module.
</p>
<p>Two parallel approaches will be developed and compared:</p>
<ol>
<li>
<strong>Greenfield integration</strong> (led by @lussoluca and @mxr576): A clean-slate integration that adheres as closely as possible to the Platform component's API, exposing its abstractions directly to Drupal. Backward and forward compatibility with the current AI Provider API is explicitly not a goal, or only a best-effort concern.
</li>
<li>
<strong>Backward-compatibility-focused integration</strong> (led by @fago and @admitriiev): An integration that wraps or maps the Symfony AI Platform API onto the existing AI module's provider abstractions, preserving compatibility for existing consumers as much as possible.
</li>
</ol>
<p>
Both approaches will be evaluated against each other. The evaluation criteria include design quality, developer experience, maintainability, compatibility implications, and the migration path for existing AI provider implementations and consumers. Once an approach is agreed upon, it will be merged into the AI module as the canonical implementation.
</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ul>
<li>Implement the greenfield integration prototype (@lussoluca, @mxr576)</li>
<li>Implement the backward-compatibility-focused prototype (@fago, @admitriiev)</li>
<li>Review and compare both prototypes as a group</li>
<li>Document pros and cons for each approach</li>
<li>Reach agreement on the preferred approach</li>
<li>Commit the accepted solution to the AI module - TBD whether this gets committed to 1.x as well with deprecation triggers</li>
</ul>
<h3>Phase 2: Prototype development</h3>
<p>Plan is that 2.x introduces Platform Provider Plugins, Multi-instance, Drops support for AI-Providers</p>
<ul>
<li> We keep BC for operation types / business layer and select a configured platform instance to use per operation type</li>
<li> We probably need to keep operation-type focused API and provide a Symfony-based replacement</li>
<li> Generally, we mark to-be-removed API as deprecated and establish new Symfony-platform focused API</li>
<li> After that, we continue flushing out the new Symfony-focused API. </li>
<li>
</ul>
<h3 id="summary-additional-information">Additional information</h3>
<ul>
<li>POC issue: <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-5"><a href="https://www.drupal.org/project/ai/issues/3565674" title="Status: Closed (won't fix)">#3565674: Create first version of the abstraction layer using Symfony AI v0.1.0</a></span></li>
<li>Symfony AI Platform component documentation: <a href="https://symfony.com/doc/current/ai/components/platform.html">https://symfony.com/doc/current/ai/components/platform.html</a></li>
<li>Symfony AI Platform Component on GitHub: <a href="https://github.com/symfony/ai/tree/main/src/platform">https://github.com/symfony/ai/tree/main/src/platform</a></li>
<li>Note: The Symfony AI components are currently under development but @chertel already confirmed that the Platform's APIs are close to stable so we can start working on the integraiton.</li>
</ul>
<h3>Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)</h3>
<h3 id="summary-related-symfony-ai-issues">Related Symfony AI issues</h3>
<p><a href="https://github.com/symfony/ai/issues/1301">Road to Symfony AI v1.0</a></p>
<p><strong>Issues we opened or keep an eye on:</strong></p>
<ul>
<li><a href="https://github.com/symfony/ai/issues/1648">[Platform] Add a human-readable label to models</a> - would reduce the necessary glue code for exposing a Plaform implementation (as a plugin) in Drupal</li>
<li><a href="https://github.com/symfony/ai/issues/1637">[Platform] Improve documentation of thrown exceptions</a> - would make Platform APIs consumption more resilient at the integration level and exposing it as primary APIs for LLM communication in Drupal AI</li>
<li><a href="https://github.com/symfony/ai/issues/1753">[Platform] Clarify BC policy for model IDs exposed by model catalogs</a> - Model IDs used to be stored in configuration, we need to know if we could rely on model IDs returned by Platform implementation and what are the rules we must follow</li>
<li><del>2026.04.11: <a href="https://github.com/symfony/ai/pull/1923">[Platform] Introduce Provider abstraction and model routing layer</a> - iif this lands, we should revisit our integration bridge, since AI Platform plugins may effectively become Provider plugins, which would introduce a naming overlap on our side. =]</del> 0.8.0 is out with this change, we have to decide how to adopt</li>
</ul>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<p>[ ] AI Assisted Issue<br>
This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
<p>[x] AI Assisted Code<br>
This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p>
<p>[ ] AI Generated Code<br>
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</p>
<p>[ ] Vibe Coded<br>
This code was generated by an AI and has only been functionally tested.</p>
> Related issue: [Issue #3538499](https://www.drupal.org/node/3538499)
issue