diff --git a/src/Provider/OpenAIProvider.php b/src/Provider/OpenAIProvider.php index ed2888d..4d42521 100644 --- a/src/Provider/OpenAIProvider.php +++ b/src/Provider/OpenAIProvider.php @@ -54,11 +54,11 @@ final class OpenAIProvider implements LLMProviderInterface array $config = [], ) { $host = $config['host'] ?? 'https://api.openai.com/v1'; - $key = $config['key'] ?? ($_SERVER['OPENAI_API_KEY'] ?? null); + $key = $config['key'] ?? ($_SERVER['JSONFICATOR_OPENAI_API_KEY'] ?? $_ENV['JSONFICATOR_OPENAI_API_KEY'] ?? null); if ($key === null || $key === '') { throw new ProviderException( - 'OpenAI API key is required. Provide it via the "key" config option or the OPENAI_API_KEY environment variable.' + 'OpenAI API key is required. Provide it via the "key" config option or the JSONFICATOR_OPENAI_API_KEY environment variable.' ); } diff --git a/tests/Integration/OpenAIIntegrationTest.php b/tests/Integration/OpenAIIntegrationTest.php index e583798..0d81bc1 100644 --- a/tests/Integration/OpenAIIntegrationTest.php +++ b/tests/Integration/OpenAIIntegrationTest.php @@ -33,8 +33,9 @@ final class OpenAIIntegrationTest extends TestCase public function testToJsonExtractsData(): void { $provider = new OpenAIProvider([ + 'host' => 'https://llm.geckon01.ru', 'key' => self::$apiKey, - 'model' => 'gpt-4o-mini', + 'model' => 'gemma4:latest', ]); $jsonFicator = new JsonFicator($provider); diff --git a/tests/Unit/OpenAIProviderTest.php b/tests/Unit/OpenAIProviderTest.php index 9fb9286..a4f41d5 100644 --- a/tests/Unit/OpenAIProviderTest.php +++ b/tests/Unit/OpenAIProviderTest.php @@ -39,13 +39,13 @@ final class OpenAIProviderTest extends TestCase public function testAcceptsApiKeyFromEnvironment(): void { - $_SERVER['OPENAI_API_KEY'] = 'sk-env'; + $_SERVER['JSONFICATOR_OPENAI_API_KEY'] = 'sk-env'; try { $provider = new OpenAIProvider(); $this->assertInstanceOf(OpenAIProvider::class, $provider); } finally { - unset($_SERVER['OPENAI_API_KEY']); + unset($_SERVER['JSONFICATOR_OPENAI_API_KEY']); } } }