Skip to main content

aip_sdk.AsyncAPIClient

aip_sdk.AsyncAPIClient(base_url: str | None = None, api_key: str | None = None, impersonate_user_id: str | None = None, token: str | None = None, workspace_id: str | None = None, *, user_id: str | None = None, _auto_login: bool = True)

Asynchronous HTTP client for AIP v2 API.

Drop-in async counterpart to APIClient. Uses httpx.AsyncClient internally; all public methods are coroutines and must be awaited.

Auth precedence: JWT Bearer token > x-api-key > unauthenticated. impersonate_user_id is not a credential — it is an admin-only override layered on top of whichever credential authenticates the call.

Parameters

  • base_url str | None: Base URL of the aip-api service.
  • api_key str | None: Long-lived API key, sent as x-api-key.
  • impersonate_user_id str | None: Admin-only override scoping calls to another user's data, sent as x-user-id. Ignored for non-admin credentials.
  • token str | None: Pre-obtained JWT. Short-lived, and never refreshed by this client.
  • workspace_id str | None: Default workspace for calls that take one.
  • user_id str | None: Deprecated alias for impersonate_user_id.

Example:

async with AsyncAPIClient(base_url=..., api_key=...) as client:
data = await client.get("/suts")

aip_sdk.AsyncAPIClient.close​

async aip_sdk.AsyncAPIClient.close() -> None

Close the underlying async HTTP connection pool and any cached sync client.

aip_sdk.AsyncAPIClient.delete​

async aip_sdk.AsyncAPIClient.delete(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

DELETE via request(); see it for scope/workspace and the other kwargs.

aip_sdk.AsyncAPIClient.get​

async aip_sdk.AsyncAPIClient.get(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

GET via request(); see it for scope/workspace and the other kwargs.

aip_sdk.AsyncAPIClient.is_closed​

aip_sdk.AsyncAPIClient.is_closed: bool

Whether the underlying async HTTP connection pool has been closed.

aip_sdk.AsyncAPIClient.patch​

async aip_sdk.AsyncAPIClient.patch(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

PATCH via request(); see it for scope/workspace and the other kwargs.

aip_sdk.AsyncAPIClient.post​

async aip_sdk.AsyncAPIClient.post(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

POST via request(); see it for scope/workspace and the other kwargs.

aip_sdk.AsyncAPIClient.put​

async aip_sdk.AsyncAPIClient.put(path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, **kwargs: Any) -> Any

PUT via request(); see it for scope/workspace and the other kwargs.

aip_sdk.AsyncAPIClient.reopen​

aip_sdk.AsyncAPIClient.reopen() -> None

Re-open the async HTTP connection pool if it was previously closed.

A no-op when already open. Mirrors APIClient.reopen() so a module-level default async client survives an owning ``async with aip.arun(...)`` block closing it. Also drops any cached sync client (closed alongside this one in close()) so it is lazily rebuilt fresh on the next _sync_from_async call instead of staying closed.

aip_sdk.AsyncAPIClient.request​

async aip_sdk.AsyncAPIClient.request(method: str, path: str, *, scope: WorkspaceScope | None = None, workspace: WorkspaceRequest | ResolvedWorkspace | None = None, json: dict[str, Any] | None = None, params: dict[str, Any] | None = None, files: dict[str, Any] | None = None, data: dict[str, Any] | None = None, headers: dict[str, str] | None = None) -> Any

Make an authenticated async request with automatic retry on transient failures.

Parameters

  • method str: The HTTP method, e.g. "GET".
  • path str: The request path, relative to the client's configured base_url.
  • scope WorkspaceScope | None: Which workspace-resolution mode this call declares, without saying where the resolved value goes — see WorkspaceScope. Resolved into a query parameter. Omitting it warns and resolves nothing; it will become required in a future release. get/post/patch/put/ delete default it to WorkspaceScope.NONE; that default goes away with this deprecation.
  • workspace WorkspaceRequest | ResolvedWorkspace | None: The full declaration — how to resolve the workspace and where to send it (see WorkspaceRequest). Pass this or scope, not both. Pass a ResolvedWorkspace to place an already-resolved value.
  • json dict[str, Any] | None: JSON request body.
  • params dict[str, Any] | None: Query string parameters.
  • files dict[str, Any] | None: Multipart file uploads.
  • data dict[str, Any] | None: Form-encoded request body.
  • headers dict[str, str] | None: Extra headers, merged over the client's own auth headers.

Returns

  • Any: The parsed JSON response body, or None for a 204 or empty body.

Raises

Inherited members​

Inherited from libs/aip-sdk/src/aip_sdk/client.py

aip_sdk.AsyncAPIClient.config​

aip_sdk.AsyncAPIClient.config = get_config(base_url=base_url, api_key=api_key, impersonate_user_id=impersonate_user_id, token=token, workspace_id=workspace_id)

No docstring is defined in the source.

Inherited from libs/aip-sdk/src/aip_sdk/client.py

aip_sdk.AsyncAPIClient.resolve_workspace​

aip_sdk.AsyncAPIClient.resolve_workspace(spec: WorkspaceRequest) -> ResolvedWorkspace

Resolve a workspace declaration now, before the request is made.

For a call that needs the resolved workspace in its own code — to name it in an error message, build a path from it, choose between two routes, or filter a response. Pass the result straight back as request(workspace=...): it is already resolved, so nothing resolves twice and the value sent cannot drift from the value used.

Parameters

Returns

Raises