refactor: streamline API key retrieval in transcription and TTS tools

- Removed fallback to OPENAI_API_KEY in favor of exclusively using VOICE_TOOLS_OPENAI_KEY for improved clarity and consistency.
- Updated environment variable checks to ensure only VOICE_TOOLS_OPENAI_KEY is considered, enhancing error handling and messaging.
This commit is contained in:
teknium1 2026-02-26 19:56:42 -08:00
parent 715825eac3
commit a5ea272936
2 changed files with 4 additions and 7 deletions

View file

@ -50,10 +50,7 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> dict:
- "transcript" (str): The transcribed text (empty on failure)
- "error" (str, optional): Error message if success is False
"""
# Use VOICE_TOOLS_OPENAI_KEY to avoid interference with the OpenAI SDK's
# auto-detection of OPENAI_API_KEY (which would break OpenRouter calls).
# Falls back to OPENAI_API_KEY for backward compatibility.
api_key = os.getenv("VOICE_TOOLS_OPENAI_KEY") or os.getenv("OPENAI_API_KEY")
api_key = os.getenv("VOICE_TOOLS_OPENAI_KEY")
if not api_key:
return {
"success": False,