Skip to contents

This function checks whether the API key provided in the OPENAI_API_KEY environment variable is valid. This function will not re-check an API if it has already been validated in the current session.

Usage

check_api()

Value

Nothing is returned. If the API key is valid, a success message is printed. If the API key is invalid, an error message is printed and the function aborts.

Examples

# Call the function to check the API key
if (FALSE) {
check_api()
}