You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/swarms/utils/check_swarms_api_key.py

20 lines
558 B

import os
def check_swarms_api_key():
"""
Check if the Swarms API key is set.
Returns:
str: The value of the SWARMS_API_KEY environment variable.
Raises:
ValueError: If the SWARMS_API_KEY environment variable is not set.
"""
if os.getenv("SWARMS_API_KEY") is None:
raise ValueError(
"Swarms API key is not set. Please set the SWARMS_API_KEY environment variable. "
"You can get your key here: https://swarms.world/platform/api-keys"
)
return os.getenv("SWARMS_API_KEY")