IBM watsonx.governance as a service

Requirements

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

Authentication

Note

Depending on the region of your provisioned service instance, use one of the following as your region.

us-south, eu-de, au-syd, ca-tor, jp-tok

Note

To determine your api_key, refer to IBM Cloud console API keys.

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_APIKEY"] = "..."
    
    # [Optional] Set the governance service instance id, incase you have multiple watsonx.governance instances.
    os.environ["WXG_SERVICE_INSTANCE_ID"] = "..."
    
    # [Optional] Set the region value to use regions other than Dallas
    from ibm_watsonx_gov.entities.enums import Region
    os.environ["WATSONX_REGION"] = Region.AU_SYD.value
    
  2. Create APIClient with default parameters for Dallas region.

    from ibm_watsonx_gov.clients.api_client import APIClient
    from ibm_watsonx_gov.credentials import Credentials
    
    credentials = Credentials(api_key=WATSONX_APIKEY)
    api_client = APIClient(credentials=credentials)
    
    # Pass the api_client object as parameter to Evaluators
    
  3. Create APIClient with the credentials object for region other than Dallas. Example shown for Sydney region.

    from ibm_watsonx_gov.clients.api_client import APIClient
    from ibm_watsonx_gov.credentials import Credentials
    from ibm_watsonx_gov.entities.enums import Region
    
    credentials = Credentials(region=Region.AU_SYD.value,
                              api_key=WATSONX_APIKEY)
    api_client = APIClient(credentials=credentials)
    
    # Pass the api_client object as parameter to Evaluators