Check if api_key is set in kwargs instead of checking for key