24 lines
633 B
Python
24 lines
633 B
Python
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import sys
|
|
from openai import OpenAI
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
def get_openrouter_client():
|
|
"""Initialize OpenRouter client with API key from .env file"""
|
|
# Load .env file
|
|
load_dotenv()
|
|
|
|
api_key = os.getenv('OPENROUTER_API_KEY')
|
|
if not api_key or api_key == 'your_openrouter_api_key_here':
|
|
print("❌ Error: OPENROUTER_API_KEY not properly set in .env file")
|
|
print("Please update your .env file with a valid OpenRouter API key")
|
|
sys.exit(1)
|
|
|
|
return OpenAI(
|
|
base_url="https://openrouter.ai/api/v1",
|
|
api_key=api_key
|
|
)
|