module aixplain.modules.api_key
class APIKeyLimits
method __init__
__init__(
token_per_minute: int,
token_per_day: int,
request_per_minute: int,
request_per_day: int,
model: Optional[str, Model] = None
)
class APIKeyUsageLimit
method __init__
__init__(
daily_request_count: int,
daily_request_limit: int,
daily_token_count: int,
daily_token_limit: int,
model: Optional[str, Model] = None
)
Get the usage limits of an API key globally (model equals to None) or for a specific model.
Args:
daily_request_count
(int): number of requests madedaily_request_limit
(int): limit of requestsdaily_token_count
(int): number of tokens useddaily_token_limit
(int): limit of tokensmodel
(Optional[Union[Text, Model]], optional): Model which the limits apply. Defaults to None.
class APIKey
method __init__
__init__(
name: str,
expires_at: Optional[datetime, str] = None,
budget: Optional[float] = None,
asset_limits: List[APIKeyLimits] = [],
global_limits: Optional[Dict, APIKeyLimits] = None,
id: int = '',
access_key: Optional[str] = None,
is_admin: bool = False
)
method delete
delete() → None
Delete an API key by its ID
method get_usage
get_usage(asset_id: Optional[str] = None) → APIKeyUsageLimit
Get the usage limits of an API key
method set_request_per_day
set_request_per_day(
request_per_day: int,
model: Optional[str, Model] = None
) → None
Set the request per day limit of an API key
method set_request_per_minute
set_request_per_minute(
request_per_minute: int,
model: Optional[str, Model] = None
) → None
Set the request per minute limit of an API key
method set_token_per_day
set_token_per_day(token_per_day: int, model: Optional[str, Model] = None) → None
Set the token per day limit of an API key
method set_token_per_minute
set_token_per_minute(
token_per_minute: int,
model: Optional[str, Model] = None
) → None
Set the token per minute limit of an API key
method to_dict
to_dict() → Dict
Convert the APIKey object to a dictionary
method validate
validate() → None
Validate the APIKey object