@@ -459,7 +459,7 @@ public function testTokenUsageProcessorTags()
459
459
'ai ' => [
460
460
'platform ' => [
461
461
'openai ' => [
462
- 'api_key ' => 'test_key ' ,
462
+ 'api_key ' => 'sk- test_key ' ,
463
463
],
464
464
],
465
465
'agent ' => [
@@ -489,6 +489,71 @@ public function testTokenUsageProcessorTags()
489
489
$ this ->assertTrue ($ foundTag , 'Token usage processor should have output tag with full agent ID ' );
490
490
}
491
491
492
+ public function testOpenAiPlatformWithDefaultRegion ()
493
+ {
494
+ $ container = $ this ->buildContainer ([
495
+ 'ai ' => [
496
+ 'platform ' => [
497
+ 'openai ' => [
498
+ 'api_key ' => 'sk-test-key ' ,
499
+ ],
500
+ ],
501
+ ],
502
+ ]);
503
+
504
+ $ this ->assertTrue ($ container ->hasDefinition ('ai.platform.openai ' ));
505
+
506
+ $ definition = $ container ->getDefinition ('ai.platform.openai ' );
507
+ $ arguments = $ definition ->getArguments ();
508
+
509
+ $ this ->assertCount (4 , $ arguments );
510
+ $ this ->assertSame ('sk-test-key ' , $ arguments [0 ]);
511
+ $ this ->assertNull ($ arguments [3 ]); // region should be null by default
512
+ }
513
+
514
+ #[TestWith(['EU ' ])]
515
+ #[TestWith(['US ' ])]
516
+ #[TestWith([null ])]
517
+ public function testOpenAiPlatformWithRegion (?string $ region )
518
+ {
519
+ $ container = $ this ->buildContainer ([
520
+ 'ai ' => [
521
+ 'platform ' => [
522
+ 'openai ' => [
523
+ 'api_key ' => 'sk-test-key ' ,
524
+ 'region ' => $ region ,
525
+ ],
526
+ ],
527
+ ],
528
+ ]);
529
+
530
+ $ this ->assertTrue ($ container ->hasDefinition ('ai.platform.openai ' ));
531
+
532
+ $ definition = $ container ->getDefinition ('ai.platform.openai ' );
533
+ $ arguments = $ definition ->getArguments ();
534
+
535
+ $ this ->assertCount (4 , $ arguments );
536
+ $ this ->assertSame ('sk-test-key ' , $ arguments [0 ]);
537
+ $ this ->assertSame ($ region , $ arguments [3 ]);
538
+ }
539
+
540
+ public function testOpenAiPlatformWithInvalidRegion ()
541
+ {
542
+ $ this ->expectException (InvalidConfigurationException::class);
543
+ $ this ->expectExceptionMessage ('The region must be either "EU" (https://eu.api.openai.com), "US" (https://us.api.openai.com) or null (https://api.openai.com) ' );
544
+
545
+ $ this ->buildContainer ([
546
+ 'ai ' => [
547
+ 'platform ' => [
548
+ 'openai ' => [
549
+ 'api_key ' => 'sk-test-key ' ,
550
+ 'region ' => 'INVALID ' ,
551
+ ],
552
+ ],
553
+ ],
554
+ ]);
555
+ }
556
+
492
557
private function buildContainer (array $ configuration ): ContainerBuilder
493
558
{
494
559
$ container = new ContainerBuilder ();
0 commit comments