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_idstr: SUT registration IDclientAsyncAPIClient | None: Optional async API client
Returns
SutInstance: SutInstance
Raises
SutNotFoundError: If SUT doesn't exist
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
namestr: SUT name to look up or register.versionstr: Version string (used only when registering).ownerstr | None: Owner identifier (used only when registering).project_idstr | 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_idstr | None: Scope the lookup and registration to this workspace when noproject_idis given. Falls back to the client config'sworkspace_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 aDuplicateSutErrorraised for one that already exists here.clientAsyncAPIClient | None: Optional async API client.
Returns
SutInstance:(sut, created)— the SutInstance andTruewhen freshlybool: registered,Falsewhen an existing SUT was found.
Raises
InvalidArgumentError: If bothproject_idandworkspace_idare given — a project already determines its workspace.NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.
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_idstr | None: Scope the listing to this project, which determines its workspace. Not combinable withworkspace_id.workspace_idstr | None: Filter by workspace (matches SUTs scoped to the workspace directly or via a project in it)pageint: Page number (1-indexed)per_pageint: Results per pageclientAsyncAPIClient | None: Optional async API clientall_workspacesbool: Read across every workspace you can access.
Returns
list[SutInstance]: List of SutInstance objects
Raises
ForbiddenError: Ifworkspace_idnames a workspace the caller cannot access.InvalidArgumentError: Ifworkspace_idis combined withall_workspaces, or withproject_id— a project already determines its workspace.NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, andall_workspaceswas 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
namestr: SUT nameversionstr: Version identifierownerstr | None: Owner/team identifierproject_idstr | None: Associated project IDworkspace_idstr | None: Workspace to scope the SUT to. Pass this orproject_id, not both — a project-scoped SUT inherits its workspace from the project. Falls back to the client config'sworkspace_id; with neither, the registration is refused rather than creating a SUT no non-admin caller can see.clientAsyncAPIClient | None: Optional async API client
Returns
SutInstance: SutInstance (with a sync client for subsequent instance method calls)
Raises
InvalidArgumentError: If bothproject_idandworkspace_idare given — a project already determines its workspace.NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.DuplicateSutError: If a SUT with this name already exists.
aip_sdk.Sut.get
aip_sdk.Sut.get(sut_id: str, client: APIClient | None = None) -> SutInstance
Fetch a registered SUT by ID.
Parameters
sut_idstr: SUT registration IDclientAPIClient | None: Optional API client
Returns
SutInstance: SutInstance
Raises
SutNotFoundError: If SUT doesn't exist
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
namestr: SUT name to look up or register.versionstr: Version string (used only when registering).ownerstr | None: Owner identifier (used only when registering).project_idstr | 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_idstr | None: Scope the lookup and registration to this workspace when noproject_idis given. Falls back to the client config'sworkspace_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 aDuplicateSutErrorraised for one that already exists here.clientAPIClient | None: Optional API client.
Returns
SutInstance:(sut, created)— the SutInstance andTruewhen freshlybool: registered,Falsewhen an existing SUT was found.
Raises
InvalidArgumentError: If bothproject_idandworkspace_idare given — a project already determines its workspace.NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.
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_idstr | None: Scope the listing to this project, which determines its workspace. Not combinable withworkspace_id.workspace_idstr | None: Filter by workspace (matches SUTs scoped to the workspace directly or via a project in it)pageint: Page number (1-indexed)per_pageint: Results per pageclientAPIClient | None: Optional API clientall_workspacesbool: Read across every workspace you can access.
Returns
list[SutInstance]: List of SutInstance objects
Raises
ForbiddenError: Ifworkspace_idnames a workspace the caller cannot access.InvalidArgumentError: Ifworkspace_idis combined withall_workspaces, or withproject_id— a project already determines its workspace.NoWorkspaceSelectedError: No workspace was passed, none is configured for the session, andall_workspaceswas 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
namestr: SUT nameversionstr: Version identifierownerstr | None: Owner/team identifierproject_idstr | None: Associated project IDworkspace_idstr | None: Workspace to scope the SUT to. Pass this orproject_id, not both — a project-scoped SUT inherits its workspace from the project. Falls back to the client config'sworkspace_id; with neither, the registration is refused rather than creating a SUT no non-admin caller can see.clientAPIClient | None: Optional API client
Returns
SutInstance: SutInstance
Raises
InvalidArgumentError: If bothproject_idandworkspace_idare given — a project already determines its workspace.NoWorkspaceSelectedError: If no workspace is passed and none is configured for the session.DuplicateSutError: If a SUT with this name already exists.
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 descriptiondict[str, Any]: -sut_protocol: invocation protocol identifierdict[str, Any]: -gdi_schema: expected GDI dataset schemadict[str, Any]: -model_params: default model params for this templatedict[str, Any]: -params_schema: JSON Schema dict for valid model_params (if the builder declares one), suitable for validation or UI renderingdict[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"])