IBM watsonx.governance

Requirements

For information on how to start working with IBM watsonx.governance, refer to: Getting started with IBM watsonx.governance.

Authentication

Users of IBM watsonx.governance can initialize an IBM watsonx.governance Python client by providing their credentials.

Note

To determine your <WATSONX_APIKEY>, refer to Generating API keys.. The base URL for ibm-watsonx-gov comes from the cluster and add-on service instance. The URL follows this pattern:

https://{cpd_cluster}‘

{cpd_cluster} represents the name or IP address of your deployed cluster. For the Cloud Pak for Data system, use a hostname that resolves to an IP address in the cluster.

To find the base URL, view the details for the service instance from the Cloud Pak for Data web client. Use that URL in your requests to watsonx.governance.


Note

The WATSONX_VERSION value should be set to the two-digit release version number separated by a dot (e.g., ‘2.2’) for the IBM watsonx.governance you are using.

To use the functionality in ibm-watsonx-gov, the required credentials can be set in enviroment variables or using APIClient object.

Examples:
  1. Set the credentials using environment variables. When environment variables are used, the APIClient reads and initializes them only once. If any of the environment variable values are changed, the Python process or the notebook kernel must be restarted for the new values to take effect.

    os.environ["WATSONX_URL"] = "..."
    os.environ["WATSONX_APIKEY"] = "..."
    os.environ["WATSONX_USERNAME"] = "..."
    os.environ["WATSONX_VERSION"] = "..."
    # One for WATSONX_APIKEY or WATSONX_PASSWORD can be used.
    # os.environ["WATSONX_PASSWORD"] = "..."
    
  2. Create APIClient.

    from ibm_watsonx_gov.clients.api_client import APIClient
    from ibm_watsonx_gov.credentials import Credentials
    
    credentials = Credentials(url=WATSONX_URL,
                              api_key=WATSONX_APIKEY,
                              username=WATSONX_USERNAME,
                              version=WATSONX_VERSION)
    api_client = APIClient(credentials=credentials)
    
    # Pass the api_client object as parameter to Evaluators