aixplain.v2.client
Client module for making HTTP requests to the aiXplain API.
create_retry_session
def create_retry_session(total: Optional[int] = None,
backoff_factor: Optional[float] = None,
status_forcelist: Optional[List[int]] = None,
**kwargs: Any) -> requests.Session
Creates a requests.Session with a specified retry strategy.
Arguments:
totalint, optional - Total number of retries allowed. Defaults to 5.backoff_factorfloat, optional - Backoff factor to apply between retry attempts. Defaults to 0.1.status_forcelistlist, optional - List of HTTP status codes to force a retry on. Defaults to [500, 502, 503, 504].kwargsdict, optional - Additional keyword arguments for internal Retry object.
Returns:
requests.Session- A requests.Session object with the specified retry strategy.
AixplainClient Objects
class AixplainClient()
HTTP client for aiXplain API with retry support.
__init__
def __init__(
base_url: str,
aixplain_api_key: Optional[str] = None,
team_api_key: Optional[str] = None,
retry_total: int = DEFAULT_RETRY_TOTAL,
retry_backoff_factor: float = DEFAULT_RETRY_BACKOFF_FACTOR,
retry_status_forcelist: List[int] = DEFAULT_RETRY_STATUS_FORCELIST
) -> None
Initializes AixplainClient with authentication and retry configuration.
Arguments:
base_urlstr - The base URL for the API.aixplain_api_keystr, optional - The individual API key.team_api_keystr, optional - The team API key.retry_totalint, optional - Total number of retries allowed. Defaults to None, uses DEFAULT_RETRY_TOTAL.retry_backoff_factorfloat, optional - Backoff factor to apply between retry attempts. Defaults to None, uses DEFAULT_RETRY_BACKOFF_FACTOR.retry_status_forcelistlist, optional - List of HTTP status codes to force a retry on. Defaults to None, uses DEFAULT_RETRY_STATUS_FORCELIST.
request_raw
def request_raw(method: str, path: str, **kwargs: Any) -> requests.Response
Sends an HTTP request.
Arguments:
methodstr - HTTP method (e.g. 'GET', 'POST')pathstr - URL path or full URLkwargsdict, optional - Additional keyword arguments for the request
Returns:
requests.Response- The response from the request
request
def request(method: str, path: str, **kwargs: Any) -> dict
Sends an HTTP request.
Arguments:
methodstr - HTTP method (e.g. 'GET', 'POST')pathstr - URL pathkwargsdict, optional - Additional keyword arguments for the request
Returns:
dict- The response from the request
get
def get(path: str, **kwargs: Any) -> dict
Sends an HTTP GET request.
Arguments:
pathstr - URL pathkwargsdict, optional - Additional keyword arguments for the request
Returns:
requests.Response- The response from the request