llm_providers¶
The following methods allow for interaction with the Zscaler AI Guard LLM Providers API endpoints. Includes listing, creating, updating, and deleting LLM providers, retrieving a provider by ID or name, listing provider types, and running referential checks.
Methods are accessible via aiguard.llm_providers
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 LLMProvidersAPI¶
Bases:
APIClientA Client object for the AI Guard LLM Providers resource.
- add_provider(**kwargs)¶
Creates a new LLM provider.
- Parameters:
name (str) – The name of the LLM provider.
**kwargs – Optional keyword args.
- Keyword Arguments:
- Returns:
A tuple containing the newly added LlmProviders instance, response, and error.
- Return type:
Examples
Add a new public LLM provider:
>>> added_provider, _, error = client.aiguard.llm_providers.add_provider( ... name="BDAnthropic", ... type="xai", ... public=True, ... ) >>> if error: ... print(f"Error adding LLM provider: {error}") ... return ... print(f"LLM provider added successfully: {added_provider.as_dict()}")
- Note:
A private provider (
public=False) additionally requires aserverspayload. Uselist_provider_types()to discover the supported values fortype.
- delete_provider(provider_id)¶
Deletes the specified LLM provider.
- Parameters:
provider_id (int) – The unique identifier for the LLM provider.
- Returns:
A tuple containing the response object and error (if any).
- Return type:
Examples
Delete a LLM provider:
>>> _, _, error = client.aiguard.llm_providers.delete_provider(1013) >>> if error: ... print(f"Error deleting LLM provider: {error}") ... return ... print(f"Llm provider deleted successfully.")
- get_provider(provider_id)¶
Fetches a specific LLM provider by ID.
- Parameters:
provider_id (int) – The unique identifier for the LLM provider.
- Returns:
A tuple containing (LlmProviders instance, Response, error).
- Return type:
Examples
Print a specific LLM provider:
>>> fetched_provider, _, error = client.aiguard.llm_providers.get_provider(1013) >>> if error: ... print(f"Error fetching LLM provider by ID: {error}") ... return ... print(f"Fetched LLM provider by ID: {fetched_provider.as_dict()}")
- get_provider_by_name(name)¶
Fetches a specific LLM provider by name.
- Parameters:
name (str) – The name of the LLM provider.
- Returns:
A tuple containing (LlmProviders instance, Response, error).
- Return type:
Examples
Print a specific LLM provider by name:
>>> fetched_provider, _, error = client.aiguard.llm_providers.get_provider_by_name('Provider01') >>> if error: ... print(f"Error fetching LLM provider by name: {error}") ... return ... print(f"Fetched LLM provider by name: {fetched_provider.as_dict()}")
- get_provider_type(provider_type)¶
Fetches details for a specific LLM provider type.
- Parameters:
provider_type (str) – The LLM provider type (e.g.
OPENAI).- Returns:
A tuple containing (the raw response value, Response, error).
- Return type:
Examples
>>> result, _, error = client.aiguard.llm_providers.get_provider_type('OPENAI') >>> if error: ... print(f"Error calling get_provider_type: {error}") ... return ... print(f"Result: {result}")
- list_provider_types(query_params=None)¶
Lists the LLM provider types supported by AI Guard.
- Parameters:
{dict} (query_params) – Map of query parameters for the request.
- Returns:
A tuple containing (list of LLM providers, Response, error)
- Return type:
Examples
List LLM providers:
>>> provider_list, _, error = client.aiguard.llm_providers.list_provider_types() >>> if error: ... print(f"Error listing LLM providers: {error}") ... return ... print(f"Total LLM providers found: {len(provider_list)}") ... for provider in provider_list: ... print(provider.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.
- list_providers(query_params=None)¶
Lists the LLM providers configured in your organization.
- Parameters:
{dict} (query_params) – Map of query parameters for the request.
- Returns:
A tuple containing (list of LlmProviders instances, Response, error)
- Return type:
Examples
List LLM providers:
>>> provider_list, _, error = client.aiguard.llm_providers.list_providers() >>> if error: ... print(f"Error listing LLM providers: {error}") ... return ... print(f"Total LLM providers found: {len(provider_list)}") ... for provider in provider_list: ... print(provider.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_provider(provider_id, **kwargs)¶
Updates information for the specified LLM provider.
- Parameters:
provider_id (int) – The unique identifier for the LLM provider.
- Keyword Arguments:
- Returns:
A tuple containing the updated LlmProviders instance, response, and error.
- Return type:
Examples
Update an existing LLM provider:
>>> updated_provider, _, error = client.aiguard.llm_providers.update_provider( ... provider_id=29103, ... name="BDAnthropic_Updated", ... type="xai", ... public=False, ... ) >>> if error: ... print(f"Error updating LLM provider: {error}") ... return ... print(f"LLM provider updated successfully: {updated_provider.as_dict()}")
- Note:
Public providers are not editable – the API rejects the update with “A public provider is not editable.”