Skip to main content
Version: 2.0

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

[view_source]

Creates a requests.Session with a specified retry strategy.

Arguments:

  • total int, optional - Total number of retries allowed. Defaults to 5.
  • backoff_factor float, optional - Backoff factor to apply between retry attempts. Defaults to 0.1.
  • status_forcelist list, optional - List of HTTP status codes to force a retry on. Defaults to [500, 502, 503, 504].
  • kwargs dict, optional - Additional keyword arguments for internal Retry object.

Returns:

  • requests.Session - A requests.Session object with the specified retry strategy.

AixplainClient Objects

class AixplainClient()

[view_source]

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

[view_source]

Initializes AixplainClient with authentication and retry configuration.

Arguments:

  • base_url str - The base URL for the API.
  • aixplain_api_key str, optional - The individual API key.
  • team_api_key str, optional - The team API key.
  • retry_total int, optional - Total number of retries allowed. Defaults to None, uses DEFAULT_RETRY_TOTAL.
  • retry_backoff_factor float, optional - Backoff factor to apply between retry attempts. Defaults to None, uses DEFAULT_RETRY_BACKOFF_FACTOR.
  • retry_status_forcelist list, 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

[view_source]

Sends an HTTP request.

Arguments:

  • method str - HTTP method (e.g. 'GET', 'POST')
  • path str - URL path or full URL
  • kwargs dict, 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

[view_source]

Sends an HTTP request.

Arguments:

  • method str - HTTP method (e.g. 'GET', 'POST')
  • path str - URL path
  • kwargs dict, optional - Additional keyword arguments for the request

Returns:

  • dict - The response from the request

get

def get(path: str, **kwargs: Any) -> dict

[view_source]

Sends an HTTP GET request.

Arguments:

  • path str - URL path
  • kwargs dict, optional - Additional keyword arguments for the request

Returns:

  • requests.Response - The response from the request