@@ -23,13 +23,48 @@ def test_factory_creates_groq_stt():
2323 """Test that AIFactory creates Groq STT model."""
2424 from unittest .mock import patch
2525 import os
26-
26+
2727 # Mock the environment variable to provide an API key
2828 with patch .dict (os .environ , {'GROQ_API_KEY' : 'test-key' }):
2929 model = AIFactory .create_speech_to_text ("groq" )
3030 assert isinstance (model , GroqSpeechToTextModel )
3131
3232
33+ def test_initialization_with_api_key ():
34+ """Test initialization with api_key parameter."""
35+ model = GroqSpeechToTextModel (api_key = "test-key" )
36+ assert model .api_key == "test-key"
37+ assert model .base_url == "https://api.groq.com/openai/v1"
38+
39+
40+ def test_initialization_with_api_key_in_config ():
41+ """Test that api_key can be passed via config dict (GitHub issue #68)."""
42+ model = GroqSpeechToTextModel (config = {"api_key" : "config-test-key" })
43+ assert model .api_key == "config-test-key"
44+ assert model .base_url == "https://api.groq.com/openai/v1"
45+
46+
47+ def test_initialization_with_base_url_in_config ():
48+ """Test that base_url can be passed via config dict."""
49+ model = GroqSpeechToTextModel (
50+ api_key = "test-key" ,
51+ config = {"base_url" : "https://custom.groq.com/v1" }
52+ )
53+ assert model .base_url == "https://custom.groq.com/v1"
54+
55+
56+ def test_initialization_with_api_key_and_base_url_in_config ():
57+ """Test that both api_key and base_url can be passed via config dict."""
58+ model = GroqSpeechToTextModel (
59+ config = {
60+ "api_key" : "config-test-key" ,
61+ "base_url" : "https://custom.groq.com/v1"
62+ }
63+ )
64+ assert model .api_key == "config-test-key"
65+ assert model .base_url == "https://custom.groq.com/v1"
66+
67+
3368def test_groq_transcribe (audio_file ):
3469 """Test Groq transcribe method with httpx mocking."""
3570 from unittest .mock import Mock
0 commit comments