Spaces:
Runtime error
Runtime error
File size: 462 Bytes
96e0321 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import os
from huggingface_hub import HfApi
def get_secret():
# Try to get from environment variable first (for local development)
api_key = os.getenv("GROQ_API_KEY")
# If not found, try to get from Hugging Face secrets
if not api_key:
try:
api_key = HfApi().get_space_variable("GROQ_API_KEY")
except Exception as e:
print(f"Error getting secret: {e}")
return None
return api_key |