llm_application_credentials

The following methods allow for interaction with the Zscaler AI Guard LLM Application Credentials API endpoints. Includes listing, creating, updating, deleting, and regenerating LLM application credentials, retrieving a credential by ID or name, and running referential checks.

Methods are accessible via aiguard.llm_application_credentials

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 LLMApplicationCredentialsAPI

Bases: APIClient

A Client object for the AI Guard LLM Application Credentials resource.

add_credential(**kwargs)

Creates a new LLM application credential.

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

  • **kwargs – Optional keyword args.

Keyword Arguments:
  • application_id (str) – The application id for this LLM application credential.

  • provider_id (str) – The provider id for this LLM application credential.

  • provider_credentials_id (str) – The provider credentials id for this LLM application credential.

  • mode (str) – The mode for this LLM application credential.

Returns:

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

Return type:

tuple

Examples

Add a new LLM application credential. applicationId, providerId and providerCredentialsId must all reference existing resources:

>>> application, _, error = client.aiguard.llm_applications.get_application_by_name("App01")
>>> provider, _, error = client.aiguard.llm_providers.get_provider_by_name("Default Anthropic Provider")
>>> added_credential, _, error = client.aiguard.llm_application_credentials.add_credential(
...     applicationId=application.id,
...     providerId=provider.id,
...     providerCredentialsId=739,
...     name="IDB01",
...     mode="PROXY",
... )
>>> if error:
...     print(f"Error adding LLM application credential: {error}")
...     return
... print(f"LLM application credential added successfully: {added_credential.as_dict()}")
Note:

The create response returns a generated key – treat it as a secret and do not log it.

delete_credential(credential_id)

Deletes the specified LLM application credential.

Parameters:

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

Returns:

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

Return type:

tuple

Examples

Delete a LLM application credential:

>>> _, _, error = client.aiguard.llm_application_credentials.delete_credential(1013)
>>> if error:
...     print(f"Error deleting LLM application credential: {error}")
...     return
... print(f"Llm application credential deleted successfully.")
get_credential(credential_id)

Fetches a specific LLM application credential by ID.

Parameters:

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

Returns:

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

Return type:

tuple

Examples

Print a specific LLM application credential:

>>> fetched_credential, _, error = client.aiguard.llm_application_credentials.get_credential(1013)
>>> if error:
...     print(f"Error fetching LLM application credential by ID: {error}")
...     return
... print(f"Fetched LLM application credential by ID: {fetched_credential.as_dict()}")
get_credential_by_name(name)

Fetches a specific LLM application credential by name.

Parameters:

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

Returns:

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

Return type:

tuple

Examples

Print a specific LLM application credential by name:

>>> fetched_credential, _, error = client.aiguard.llm_application_credentials.get_credential_by_name('Credential01')
>>> if error:
...     print(f"Error fetching LLM application credential by name: {error}")
...     return
... print(f"Fetched LLM application credential by name: {fetched_credential.as_dict()}")
list_credentials(query_params=None)

Lists the LLM application credentials configured in your organization.

Parameters:

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

Returns:

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

Return type:

tuple

Examples

List LLM application credentials:

>>> credential_list, _, error = client.aiguard.llm_application_credentials.list_credentials()
>>> if error:
...     print(f"Error listing LLM application credentials: {error}")
...     return
... print(f"Total LLM application credentials found: {len(credential_list)}")
... for credential in credential_list:
...     print(credential.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.

regenerate_credential(credential_id)

Regenerates the key material for the specified LLM application credential.

Parameters:

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

Returns:

A tuple containing the resulting LlmApplicationCredentials instance, response, and error. The raw response body is available via response.get_body().

Return type:

tuple

Examples

>>> result, resp, error = client.aiguard.llm_application_credentials.regenerate_credential(1013)
>>> if error:
...     print(f"Error calling regenerate_credential: {error}")
...     return
... print(f"Action completed successfully: {result.as_dict()}")
update_credential(credential_id, **kwargs)

Updates information for the specified LLM application credential.

Parameters:

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

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

  • application_id (str) – The application id for this LLM application credential.

  • provider_id (str) – The provider id for this LLM application credential.

  • provider_credentials_id (str) – The provider credentials id for this LLM application credential.

  • mode (str) – The mode for this LLM application credential.

Returns:

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

Return type:

tuple

Examples

Update an existing LLM application credential:

>>> updated_credential, _, error = client.aiguard.llm_application_credentials.update_credential(
...     credential_id=1075,
...     applicationId=647,
...     providerId=6099,
...     providerCredentialsId=739,
...     name="IDB01_Updated",
...     mode="PROXY",
... )
>>> if error:
...     print(f"Error updating LLM application credential: {error}")
...     return
... print(f"LLM application credential updated successfully: {updated_credential.as_dict()}")