in dell_ai/client.py [0:0]
def __init__(self, token: Optional[str] = None):
"""
Initialize the Dell AI client.
Args:
token: Hugging Face API token. If not provided, will attempt to load from
the Hugging Face token cache.
Raises:
AuthenticationError: If a token is provided but invalid
"""
self.base_url = constants.API_BASE_URL
self.session = requests.Session()
# Set default headers
self.session.headers.update(
{
"Content-Type": "application/json",
"Accept": "application/json",
"User-Agent": "dell-ai-sdk/python",
}
)
# Set up authentication
self.token = token or auth.get_token()
if self.token:
# If token was explicitly provided, validate it
if token and not auth.validate_token(token):
raise AuthenticationError("Invalid authentication token provided.")
self.session.headers.update({"Authorization": f"Bearer {self.token}"})