Move API_KEY loading and create helper function