atropos/environments/hack0/protein_design_env/utils/api_utils.py
2025-05-20 20:12:59 -07:00

24 lines
617 B
Python

import os
import logging
import yaml
from pathlib import Path
from typing import Optional
from dotenv import load_dotenv
load_dotenv()
logger = logging.getLogger(__name__)
def load_api_key() -> Optional[str]:
"""
Load the NVIDIA NIM API key from environment variables.
Returns:
The API key from environment variables, or None if not found
"""
api_key = os.environ.get("NVIDIA_NIM_API_KEY")
if not api_key:
logger.error("NVIDIA_NIM_API_KEY not found in environment variables. "
"Please set it in your .env file.")
return None
return api_key