llm_provider_credentials¶
The following methods allow for interaction with the Zscaler AI Guard LLM Provider Credentials API endpoints. Includes listing, creating, updating, and deleting LLM provider credentials, retrieving a credential by ID or name, and running referential checks.
Methods are accessible via aiguard.llm_provider_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 LLMProviderCredentialsAPI¶
Bases:
APIClientA Client object for the AI Guard LLM Provider Credentials resource.
- add_credential(**kwargs)¶
Creates a new LLM provider credential.
- Parameters:
name (str) – The name of the LLM provider credential.
**kwargs – Optional keyword args.
- Keyword Arguments:
- Returns:
A tuple containing the newly added LlmProviderCredentials instance, response, and error.
- Return type:
Examples
Add a new LLM provider credential.
providerIdmust reference an existing provider – resolve it withget_provider_by_name():>>> provider, _, error = client.aiguard.llm_providers.get_provider_by_name("Default Anthropic Provider") >>> added_credential, _, error = client.aiguard.llm_provider_credentials.add_credential( ... name="Anthropic_API02", ... providerId=provider.id, ... apiCredentials={"type": "API_KEY", "key": "<provider api key>"}, ... ) >>> if error: ... print(f"Error adding LLM provider credential: {error}") ... return ... print(f"LLM provider credential added successfully: {added_credential.as_dict()}")
- Note:
apiCredentialsis write-only and is never returned in responses. Validtypevalues are API_KEY, BEARER, CROSS_ACCOUNT_ROLE, ACCESS_KEY and TRANSPARENT.expireTimeMillisis optional – omit it for credentials that do not expire.
- delete_credential(credential_id)¶
Deletes the specified LLM provider credential.
- Parameters:
credential_id (int) – The unique identifier for the LLM provider credential.
- Returns:
A tuple containing the response object and error (if any).
- Return type:
Examples
Delete a LLM provider credential:
>>> _, _, error = client.aiguard.llm_provider_credentials.delete_credential(1013) >>> if error: ... print(f"Error deleting LLM provider credential: {error}") ... return ... print(f"Llm provider credential deleted successfully.")
- get_credential(credential_id)¶
Fetches a specific LLM provider credential by ID.
- Parameters:
credential_id (int) – The unique identifier for the LLM provider credential.
- Returns:
A tuple containing (LlmProviderCredentials instance, Response, error).
- Return type:
Examples
Print a specific LLM provider credential:
>>> fetched_credential, _, error = client.aiguard.llm_provider_credentials.get_credential(1013) >>> if error: ... print(f"Error fetching LLM provider credential by ID: {error}") ... return ... print(f"Fetched LLM provider credential by ID: {fetched_credential.as_dict()}")
- get_credential_by_name(name)¶
Fetches a specific LLM provider credential by name.
- Parameters:
name (str) – The name of the LLM provider credential.
- Returns:
A tuple containing (LlmProviderCredentials instance, Response, error).
- Return type:
Examples
Print a specific LLM provider credential by name:
>>> fetched_credential, _, error = client.aiguard.llm_provider_credentials.get_credential_by_name('Credential01') >>> if error: ... print(f"Error fetching LLM provider credential by name: {error}") ... return ... print(f"Fetched LLM provider credential by name: {fetched_credential.as_dict()}")
- list_credentials(query_params=None)¶
Lists the LLM provider credentials configured in your organization.
- Parameters:
{dict} (query_params) – Map of query parameters for the request.
- Returns:
A tuple containing (list of LlmProviderCredentials instances, Response, error)
- Return type:
Examples
List LLM provider credentials:
>>> credential_list, _, error = client.aiguard.llm_provider_credentials.list_credentials() >>> if error: ... print(f"Error listing LLM provider credentials: {error}") ... return ... print(f"Total LLM provider 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.
- update_credential(credential_id, **kwargs)¶
Updates information for the specified LLM provider credential.
- Parameters:
credential_id (int) – The unique identifier for the LLM provider credential.
- Keyword Arguments:
- Returns:
A tuple containing the updated LlmProviderCredentials instance, response, and error.
- Return type:
Examples
Update an existing LLM provider credential:
>>> updated_credential, _, error = client.aiguard.llm_provider_credentials.update_credential( ... credential_id=739, ... name="Anthropic_API02_Updated", ... providerId=6099, ... apiCredentials={"type": "API_KEY", "key": "<provider api key>"}, ... ) >>> if error: ... print(f"Error updating LLM provider credential: {error}") ... return ... print(f"LLM provider credential updated successfully: {updated_credential.as_dict()}")