38
38
use Symfony \AI \Platform \Bridge \OpenAI \Embeddings ;
39
39
use Symfony \AI \Platform \Bridge \OpenAI \GPT ;
40
40
use Symfony \AI \Platform \Bridge \OpenAI \PlatformFactory as OpenAIPlatformFactory ;
41
+ use Symfony \AI \Platform \Bridge \OpenRouter \PlatformFactory as OpenRouterPlatformFactory ;
41
42
use Symfony \AI \Platform \Bridge \Voyage \Voyage ;
43
+ use Symfony \AI \Platform \Model ;
42
44
use Symfony \AI \Platform \ModelClientInterface ;
43
45
use Symfony \AI \Platform \Platform ;
44
46
use Symfony \AI \Platform \PlatformInterface ;
@@ -214,15 +216,30 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
214
216
return ;
215
217
}
216
218
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
+
217
234
if ('mistral ' === $ type ) {
218
- $ platformId = 'llm_chain .platform.mistral ' ;
235
+ $ platformId = 'symfony_ai .platform.mistral ' ;
219
236
$ definition = (new Definition (Platform::class))
220
237
->setFactory (MistralPlatformFactory::class.'::create ' )
221
238
->setAutowired (true )
222
239
->setLazy (true )
223
240
->addTag ('proxy ' , ['interface ' => PlatformInterface::class])
224
241
->setArguments (['$apiKey ' => $ platform ['api_key ' ]])
225
- ->addTag ('llm_chain .platform ' );
242
+ ->addTag ('symfony_ai .platform ' );
226
243
227
244
$ container ->setDefinition ($ platformId , $ definition );
228
245
@@ -246,6 +263,7 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
246
263
'llama ' => Llama::class,
247
264
'gemini ' => Gemini::class,
248
265
'mistral ' => Mistral::class,
266
+ 'openrouter ' => Model::class,
249
267
default => throw new \InvalidArgumentException (\sprintf ('Model "%s" is not supported. ' , $ modelName )),
250
268
};
251
269
$ modelDefinition = new Definition ($ modelClass );
0 commit comments