Skip to main content

aip_sdk.Sut

aip_sdk.Sut

SUT Registry top-level access.

Examples

>>> import aip_sdk as aip
>>> aip.init(base_url, api_key=api_key)
>>> sut = aip.Sut.register(name="my-gpt4", version="2024-01", project_id=project.id)
>>> conn = sut.add_connection(
... base_url="https://api.openai.com/v1/chat/completions",
... auth_type="bearer",
... auth_header_name="Authorization",
... auth_header_value="sk-...",
... gdi_schema="gdi_text_v1",
... )
>>> result = conn.test()
>>> print(f"Success: {result.success}, Duration: {result.duration_ms}ms")
>>> adapter = conn.set_adapter(
... template_name="openai_chat", mapping_config={"sut_response": "$.choices[0].message.content"}
... )
>>> sample = {"choices": [{"message": {"content": "Hello"}}]}
>>> validation = adapter.validate(sample)
>>> print(validation.mapped) # {"sut_response": "Hello"}

aip_sdk.Sut.aget​

async aip_sdk.Sut.aget(sut_id: str, client: AsyncAPIClient | None = None) -> SutInstance

Async variant of get().

Parameters

  • sut_id str: SUT registration ID
  • client AsyncAPIClient | None: Optional async API client

Returns

Raises

aip_sdk.Sut.aget_or_register​

async aip_sdk.Sut.aget_or_register(name: str, version: str = '1.0', owner: str | None = None, project_id: str | None = None, workspace_id: str | None = None, client: AsyncAPIClient | None = None) -> tuple[SutInstance, bool]

Async variant of get_or_register().

Parameters

  • name str: SUT name to look up or register.
  • version str: Version string (used only when registering).
  • owner str | None: Owner identifier (used only when registering).
  • project_id str | None: Scope the registration to this project. The lookup widens to this project's workspace when it has one, else stays project-scoped — matching the API's own uniqueness rule.
  • workspace_id str | None: Scope the lookup and registration to this workspace when no project_id is given. Falls back to the client config's workspace_id. Scoping the lookup matters because the backend allows duplicate SUT names across workspaces — without it a same-named SUT in another workspace could be returned, or a DuplicateSutError raised for one that already exists here.
  • client AsyncAPIClient | None: Optional async API client.

Returns

  • SutInstance: (sut, created) — the SutInstance and True when freshly
  • bool: registered, False when an existing SUT was found.

Raises

aip_sdk.Sut.alist​

async aip_sdk.Sut.alist(project_id: str | None = None, workspace_id: str | None = None, page: int = 1, per_page: int = 100, client: AsyncAPIClient | None = None, *, all_workspaces: bool = False) -> list[SutInstance]

Async variant of list().

Reads your session's workspace unless you name one, and raises if none is set. Pass all_workspaces=True to read across every workspace you can access.

Parameters

  • project_id str | None: Scope the listing to this project, which determines its workspace. Not combinable with workspace_id.
  • workspace_id str | None: Filter by workspace (matches SUTs scoped to the workspace directly or via a project in it)
  • page int: Page number (1-indexed)
  • per_page int: Results per page
  • client AsyncAPIClient | None: Optional async API client
  • all_workspaces bool: Read across every workspace you can access.

Returns

  • list[SutInstance]: List of SutInstance objects

Raises

  • ForbiddenError: If workspace_id names a workspace the caller cannot access.
  • InvalidArgumentError: If workspace_id is combined with all_workspaces, or with project_id — a project already determines its workspace.
  • NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, and all_workspaces was not set.

aip_sdk.Sut.aregister​

async aip_sdk.Sut.aregister(name: str, version: str = '1.0', owner: str | None = None, project_id: str | None = None, workspace_id: str | None = None, client: AsyncAPIClient | None = None) -> SutInstance

Async variant of register().

Parameters

  • name str: SUT name
  • version str: Version identifier
  • owner str | None: Owner/team identifier
  • project_id str | None: Associated project ID
  • workspace_id str | None: Workspace to scope the SUT to. Pass this or project_id, not both — a project-scoped SUT inherits its workspace from the project. Falls back to the client config's workspace_id; with neither, the registration is refused rather than creating a SUT no non-admin caller can see.
  • client AsyncAPIClient | None: Optional async API client

Returns

  • SutInstance: SutInstance (with a sync client for subsequent instance method calls)

Raises

aip_sdk.Sut.get​

aip_sdk.Sut.get(sut_id: str, client: APIClient | None = None) -> SutInstance

Fetch a registered SUT by ID.

Parameters

  • sut_id str: SUT registration ID
  • client APIClient | None: Optional API client

Returns

Raises

aip_sdk.Sut.get_or_register​

aip_sdk.Sut.get_or_register(name: str, version: str = '1.0', owner: str | None = None, project_id: str | None = None, workspace_id: str | None = None, client: APIClient | None = None) -> tuple[SutInstance, bool]

Get an existing SUT by name or register it.

Parameters

  • name str: SUT name to look up or register.
  • version str: Version string (used only when registering).
  • owner str | None: Owner identifier (used only when registering).
  • project_id str | None: Scope the registration to this project. The lookup widens to this project's workspace when it has one, else stays project-scoped — matching the API's own uniqueness rule.
  • workspace_id str | None: Scope the lookup and registration to this workspace when no project_id is given. Falls back to the client config's workspace_id. Scoping the lookup matters because the backend allows duplicate SUT names across workspaces — without it a same-named SUT in another workspace could be returned, or a DuplicateSutError raised for one that already exists here.
  • client APIClient | None: Optional API client.

Returns

  • SutInstance: (sut, created) — the SutInstance and True when freshly
  • bool: registered, False when an existing SUT was found.

Raises

Example:

sut, created = aip.Sut.get_or_register(
name="my-detector-v1",
version="1.0",
project_id=project.id,
)
print("Registered" if created else "Reusing", sut.id)

aip_sdk.Sut.list​

aip_sdk.Sut.list(project_id: str | None = None, workspace_id: str | None = None, page: int = 1, per_page: int = 100, client: APIClient | None = None, *, all_workspaces: bool = False) -> list[SutInstance]

List registered SUTs.

Reads your session's workspace unless you name one, and raises if none is set. Pass all_workspaces=True to read across every workspace you can access.

Parameters

  • project_id str | None: Scope the listing to this project, which determines its workspace. Not combinable with workspace_id.
  • workspace_id str | None: Filter by workspace (matches SUTs scoped to the workspace directly or via a project in it)
  • page int: Page number (1-indexed)
  • per_page int: Results per page
  • client APIClient | None: Optional API client
  • all_workspaces bool: Read across every workspace you can access.

Returns

  • list[SutInstance]: List of SutInstance objects

Raises

  • ForbiddenError: If workspace_id names a workspace the caller cannot access.
  • InvalidArgumentError: If workspace_id is combined with all_workspaces, or with project_id — a project already determines its workspace.
  • NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, and all_workspaces was not set.

aip_sdk.Sut.register​

aip_sdk.Sut.register(name: str, version: str = '1.0', owner: str | None = None, project_id: str | None = None, workspace_id: str | None = None, client: APIClient | None = None) -> SutInstance

Register a new System Under Test.

Parameters

  • name str: SUT name
  • version str: Version identifier
  • owner str | None: Owner/team identifier
  • project_id str | None: Associated project ID
  • workspace_id str | None: Workspace to scope the SUT to. Pass this or project_id, not both — a project-scoped SUT inherits its workspace from the project. Falls back to the client config's workspace_id; with neither, the registration is refused rather than creating a SUT no non-admin caller can see.
  • client APIClient | None: Optional API client

Returns

Raises

Examples

>>> sut = aip.Sut.register(name="production-gpt4", version="2024-01-15", project_id=project.id)

aip_sdk.Sut.templates​

aip_sdk.Sut.templates(client: APIClient | None = None) -> dict[str, Any]

List all built-in adapter templates.

Returns

  • dict[str, Any]: Dict of template name → template config. Each entry includes:
  • dict[str, Any]: - description: human-readable description
  • dict[str, Any]: - sut_protocol: invocation protocol identifier
  • dict[str, Any]: - gdi_schema: expected GDI dataset schema
  • dict[str, Any]: - model_params: default model params for this template
  • dict[str, Any]: - params_schema: JSON Schema dict for valid model_params (if the builder declares one), suitable for validation or UI rendering
  • dict[str, Any]: - mapping_config: default JSONPath response mappings

Examples

>>> templates = aip.Sut.templates()
>>> print(templates["openai_chat"]["mapping_config"])
>>> print(templates["openai_chat"]["params_schema"])