llm_applications

The following methods allow for interaction with the Zscaler AI Guard LLM Applications API endpoints. Includes listing, creating, updating, and deleting LLM applications, retrieving an application by ID or name, and running referential checks.

Methods are accessible via aiguard.llm_applications

Copyright (c) 2023, Zscaler Inc.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

class LLMApplicationsAPI

Bases: APIClient

A Client object for the AI Guard LLM Applications resource.

add_application(**kwargs)

Creates a new LLM application.

Parameters:
  • name (str) – The name of the LLM application.

  • **kwargs – Optional keyword args.

Keyword Arguments:
  • owner_email (str) – The owner email for this LLM application.

  • application_settings (str) – The application settings for this LLM application.

Returns:

A tuple containing the newly added LlmApplications instance, response, and error.

Return type:

tuple

Examples

Add a new LLM application:

>>> added_application, _, error = client.aiguard.llm_applications.add_application(
...     name="App10",
...     ownerEmail="jdoe@acme.com",
...     applicationSettings={
...         "includeEventContents": True,
...         "encryptEventContents": False,
...     },
... )
>>> if error:
...     print(f"Error adding LLM application: {error}")
...     return
... print(f"LLM application added successfully: {added_application.as_dict()}")
Note:

Setting encryptEventContents to True requires a customer-managed key (CMK) configured in the tenant settings; the API rejects the request otherwise.

delete_application(application_id)

Deletes the specified LLM application.

Parameters:

application_id (int) – The unique identifier for the LLM application.

Returns:

A tuple containing the response object and error (if any).

Return type:

tuple

Examples

Delete a LLM application:

>>> _, _, error = client.aiguard.llm_applications.delete_application(1013)
>>> if error:
...     print(f"Error deleting LLM application: {error}")
...     return
... print(f"Llm application deleted successfully.")
get_application(application_id)

Fetches a specific LLM application by ID.

Parameters:

application_id (int) – The unique identifier for the LLM application.

Returns:

A tuple containing (LlmApplications instance, Response, error).

Return type:

tuple

Examples

Print a specific LLM application:

>>> fetched_application, _, error = client.aiguard.llm_applications.get_application(1013)
>>> if error:
...     print(f"Error fetching LLM application by ID: {error}")
...     return
... print(f"Fetched LLM application by ID: {fetched_application.as_dict()}")
get_application_by_name(name)

Fetches a specific LLM application by name.

Parameters:

name (str) – The name of the LLM application.

Returns:

A tuple containing (LlmApplications instance, Response, error).

Return type:

tuple

Examples

Print a specific LLM application by name:

>>> fetched_application, _, error = client.aiguard.llm_applications.get_application_by_name('Application01')
>>> if error:
...     print(f"Error fetching LLM application by name: {error}")
...     return
... print(f"Fetched LLM application by name: {fetched_application.as_dict()}")
list_applications(query_params=None)

Lists the LLM applications configured in your organization.

Parameters:

{dict} (query_params) – Map of query parameters for the request.

Returns:

A tuple containing (list of LlmApplications instances, Response, error)

Return type:

tuple

Examples

List LLM applications:

>>> application_list, _, error = client.aiguard.llm_applications.list_applications()
>>> if error:
...     print(f"Error listing LLM applications: {error}")
...     return
... print(f"Total LLM applications found: {len(application_list)}")
... for application in application_list:
...     print(application.as_dict())

Client-side filtering with JMESPath:

The response object supports client-side filtering and projection via resp.search(expression). See the JMESPath documentation for expression syntax.

update_application(application_id, **kwargs)

Updates information for the specified LLM application.

Parameters:

application_id (int) – The unique identifier for the LLM application.

Keyword Arguments:
  • name (str) – The name of the LLM application.

  • owner_email (str) – The owner email for this LLM application.

  • application_settings (str) – The application settings for this LLM application.

Returns:

A tuple containing the updated LlmApplications instance, response, and error.

Return type:

tuple

Examples

Update an existing LLM application:

>>> updated_application, _, error = client.aiguard.llm_applications.update_application(
...     application_id=1575,
...     name="App10_Updated",
...     ownerEmail="jdoe@acme.com",
...     applicationSettings={
...         "includeEventContents": True,
...         "encryptEventContents": False,
...     },
... )
>>> if error:
...     print(f"Error updating LLM application: {error}")
...     return
... print(f"LLM application updated successfully: {updated_application.as_dict()}")