3838use Symfony \AI \Platform \Bridge \OpenAI \Embeddings ;
3939use Symfony \AI \Platform \Bridge \OpenAI \GPT ;
4040use Symfony \AI \Platform \Bridge \OpenAI \PlatformFactory as OpenAIPlatformFactory ;
41+ use Symfony \AI \Platform \Bridge \OpenRouter \PlatformFactory as OpenRouterPlatformFactory ;
4142use Symfony \AI \Platform \Bridge \Voyage \Voyage ;
43+ use Symfony \AI \Platform \Model ;
4244use Symfony \AI \Platform \ModelClientInterface ;
4345use Symfony \AI \Platform \Platform ;
4446use Symfony \AI \Platform \PlatformInterface ;
@@ -214,15 +216,30 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
214216 return ;
215217 }
216218
219+ if ('openrouter ' === $ type ) {
220+ $ platformId = 'symfony_ai.platform.openrouter ' ;
221+ $ definition = (new Definition (Platform::class))
222+ ->setFactory (OpenRouterPlatformFactory::class.'::create ' )
223+ ->setAutowired (true )
224+ ->setLazy (true )
225+ ->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
226+ ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
227+ ->addTag ('symfony_ai.platform ' );
228+
229+ $ container ->setDefinition ($ platformId , $ definition );
230+
231+ return ;
232+ }
233+
217234 if ('mistral ' === $ type ) {
218- $ platformId = 'llm_chain .platform.mistral ' ;
235+ $ platformId = 'symfony_ai .platform.mistral ' ;
219236 $ definition = (new Definition (Platform::class))
220237 ->setFactory (MistralPlatformFactory::class.'::create ' )
221238 ->setAutowired (true )
222239 ->setLazy (true )
223240 ->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
224241 ->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
225- ->addTag ('llm_chain .platform ' );
242+ ->addTag ('symfony_ai .platform ' );
226243
227244 $ container ->setDefinition ($ platformId , $ definition );
228245
@@ -246,6 +263,7 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
246263 'llama ' => Llama::class,
247264 'gemini ' => Gemini::class,
248265 'mistral ' => Mistral::class,
266+ 'openrouter ' => Model::class,
249267 default => throw new \InvalidArgumentException (\sprintf ('Model "%s" is not supported. ' , $ modelName )),
250268 };
251269 $ modelDefinition = new Definition ($ modelClass );
0 commit comments