Credentials

pydantic model ibm_watsonx_gov.entities.credentials.AzureOpenAICredentials

Bases: BaseModel

Show JSON schema
{
   "title": "AzureOpenAICredentials",
   "type": "object",
   "properties": {
      "url": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "description": "Azure OpenAI url. This attribute can be read from `AZURE_OPENAI_HOST` environment variable.",
         "title": "Url"
      },
      "api_key": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "description": "API key for Azure OpenAI. This attribute can be read from `AZURE_OPENAI_API_KEY` environment variable.",
         "title": "Api Key"
      },
      "api_version": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "description": "The model API version from Azure OpenAI. This attribute can be read from `AZURE_OPENAI_API_VERSION` environment variable.",
         "title": "Api Version"
      }
   },
   "required": [
      "url",
      "api_key",
      "api_version"
   ]
}

Fields:
field api_key: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, description='API key for Azure OpenAI. This attribute can be read from `AZURE_OPENAI_API_KEY` environment variable.')] [Required]

API key for Azure OpenAI. This attribute can be read from AZURE_OPENAI_API_KEY environment variable.

field api_version: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, description='The model API version from Azure OpenAI. This attribute can be read from `AZURE_OPENAI_API_VERSION` environment variable.')] [Required]

The model API version from Azure OpenAI. This attribute can be read from AZURE_OPENAI_API_VERSION environment variable.

field url: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, alias_priority=2, serialization_alias='azure_openai_host', description='Azure OpenAI url. This attribute can be read from `AZURE_OPENAI_HOST` environment variable.')] [Required]

Azure OpenAI url. This attribute can be read from AZURE_OPENAI_HOST environment variable.

classmethod create_from_env()
pydantic model ibm_watsonx_gov.entities.credentials.Credentials

Bases: BaseModel

Show JSON schema
{
   "title": "Credentials",
   "type": "object",
   "properties": {
      "api_key": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The user api key. Required for using watsonx as a service and one of api_key or password is required for using watsonx on-prem software.",
         "strip_whitespace": true,
         "title": "Api Key"
      },
      "region": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "us-south",
         "description": "The watsonx cloud region. By default us-south region is used.",
         "title": "Region"
      },
      "url": {
         "default": null,
         "description": "The watsonx url. Required for using watsonx on-prem software.",
         "title": "watsonx url",
         "type": "string"
      },
      "service_instance_id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The watsonx.governance service instance id.",
         "title": "Service instance id"
      },
      "username": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The user name. Required for using watsonx on-prem software.",
         "title": "User name"
      },
      "password": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The user password. One of api_key or password is required for using watsonx on-prem software.",
         "title": "Password"
      },
      "version": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The watsonx on-prem software version. Required for using watsonx on-prem software.",
         "examples": [
            "5.2"
         ],
         "title": "Version"
      },
      "disable_ssl": {
         "default": false,
         "description": "The flag to disable ssl.",
         "title": "Disable ssl",
         "type": "boolean"
      }
   }
}

Fields:
Validators:
field api_key: ', json_schema_extra={'strip_whitespace': True})] = None

The user api key. Required for using watsonx as a service and one of api_key or password is required for using watsonx on-prem software.

Validated by:
field disable_ssl: Annotated[bool, FieldInfo(annotation=NoneType, required=False, default=False, title='Disable ssl', description='The flag to disable ssl.')] = False

The flag to disable ssl.

Validated by:
field password: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Password', description='The user password. One of api_key or password is required for using watsonx on-prem software.')] = None

The user password. One of api_key or password is required for using watsonx on-prem software.

Validated by:
field region: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default='us-south', title='Region', description='The watsonx cloud region. By default us-south region is used.')] = 'us-south'

The watsonx cloud region. By default us-south region is used.

Validated by:
field service_instance_id: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Service instance id', description='The watsonx.governance service instance id.')] = None

The watsonx.governance service instance id.

Validated by:
field url: Annotated[str, FieldInfo(annotation=NoneType, required=False, default=None, title='watsonx url', description='The watsonx url. Required for using watsonx on-prem software.')] = None

The watsonx url. Required for using watsonx on-prem software.

Validated by:
field username: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='User name', description='The user name. Required for using watsonx on-prem software.')] = None

The user name. Required for using watsonx on-prem software.

Validated by:
field version: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Version', description='The watsonx on-prem software version. Required for using watsonx on-prem software.', examples=['5.2'])] = None

The watsonx on-prem software version. Required for using watsonx on-prem software.

Validated by:
classmethod create_from_env()
validator validate_credentials  »  all fields
pydantic model ibm_watsonx_gov.entities.credentials.OpenAICredentials

Bases: BaseModel

Defines the OpenAICredentials class to specify the OpenAI server details.

Examples

  1. Create OpenAICredentials with default parameters. By default Dallas region is used.
    openai_credentials = OpenAICredentials(api_key=api_key,
                                           url=openai_url)
    
  2. Create OpenAICredentials by reading from environment variables.
    os.environ["OPENAI_API_KEY"] = "..."
    os.environ["OPENAI_URL"] = "..."
    openai_credentials = OpenAICredentials.create_from_env()
    

Show JSON schema
{
   "title": "OpenAICredentials",
   "description": "Defines the OpenAICredentials class to specify the OpenAI server details.\n\nExamples:\n    1. Create OpenAICredentials with default parameters. By default Dallas region is used.\n        .. code-block:: python\n\n            openai_credentials = OpenAICredentials(api_key=api_key,\n                                                   url=openai_url)\n\n    2. Create OpenAICredentials by reading from environment variables.\n        .. code-block:: python\n\n            os.environ[\"OPENAI_API_KEY\"] = \"...\"\n            os.environ[\"OPENAI_URL\"] = \"...\"\n            openai_credentials = OpenAICredentials.create_from_env()",
   "type": "object",
   "properties": {
      "url": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "title": "Url"
      },
      "api_key": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "title": "Api Key"
      }
   },
   "required": [
      "url",
      "api_key"
   ]
}

Fields:
field api_key: str | None [Required]
field url: str | None [Required]
classmethod create_from_env()
pydantic model ibm_watsonx_gov.entities.credentials.RITSCredentials

Bases: BaseModel

Show JSON schema
{
   "title": "RITSCredentials",
   "type": "object",
   "properties": {
      "hostname": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "https://inference-3scale-apicast-production.apps.rits.fmaas.res.ibm.com",
         "description": "The rits hostname",
         "title": "Hostname"
      },
      "api_key": {
         "title": "Api Key",
         "type": "string"
      }
   },
   "required": [
      "api_key"
   ]
}

Fields:
field api_key: str [Required]
field hostname: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default='https://inference-3scale-apicast-production.apps.rits.fmaas.res.ibm.com', description='The rits hostname')] = 'https://inference-3scale-apicast-production.apps.rits.fmaas.res.ibm.com'

The rits hostname

classmethod create_from_env()
pydantic model ibm_watsonx_gov.entities.credentials.WxAICredentials

Bases: BaseModel

Defines the WxAICredentials class to specify the watsonx.ai server details.

Examples

  1. Create WxAICredentials with default parameters. By default Dallas region is used.
    wxai_credentials = WxAICredentials(api_key="...")
    
  2. Create WxAICredentials by specifying region url.
    wxai_credentials = WxAICredentials(api_key="...",
                                       url="https://au-syd.ml.cloud.ibm.com")
    
  3. Create WxAICredentials by reading from environment variables.
    os.environ["WATSONX_APIKEY"] = "..."
    # [Optional] Specify watsonx region specific url. Default is https://us-south.ml.cloud.ibm.com .
    os.environ["WATSONX_URL"] = "https://eu-gb.ml.cloud.ibm.com"
    wxai_credentials = WxAICredentials.create_from_env()
    
  4. Create WxAICredentials for on-prem.
    wxai_credentials = WxAICredentials(url="https://<hostname>",
                                       username="..."
                                       api_key="...",
                                       version="5.2")
    
  5. Create WxAICredentials by reading from environment variables for on-prem.
    os.environ["WATSONX_URL"] = "https://<hostname>"
    os.environ["WATSONX_VERSION"] = "5.2"
    os.environ["WATSONX_USERNAME"] = "..."
    os.environ["WATSONX_APIKEY"] = "..."
    # Only one of api_key or password is needed
    #os.environ["WATSONX_PASSWORD"] = "..."
    wxai_credentials = WxAICredentials.create_from_env()
    

Show JSON schema
{
   "title": "WxAICredentials",
   "description": "Defines the WxAICredentials class to specify the watsonx.ai server details.\n\nExamples:\n    1. Create WxAICredentials with default parameters. By default Dallas region is used.\n        .. code-block:: python\n\n            wxai_credentials = WxAICredentials(api_key=\"...\")\n\n    2. Create WxAICredentials by specifying region url.\n        .. code-block:: python\n\n            wxai_credentials = WxAICredentials(api_key=\"...\",\n                                               url=\"https://au-syd.ml.cloud.ibm.com\")\n\n    3. Create WxAICredentials by reading from environment variables.\n        .. code-block:: python\n\n            os.environ[\"WATSONX_APIKEY\"] = \"...\"\n            # [Optional] Specify watsonx region specific url. Default is https://us-south.ml.cloud.ibm.com .\n            os.environ[\"WATSONX_URL\"] = \"https://eu-gb.ml.cloud.ibm.com\"\n            wxai_credentials = WxAICredentials.create_from_env()\n\n    4. Create WxAICredentials for on-prem.\n        .. code-block:: python\n\n            wxai_credentials = WxAICredentials(url=\"https://<hostname>\",\n                                               username=\"...\"\n                                               api_key=\"...\",\n                                               version=\"5.2\")\n\n    5. Create WxAICredentials by reading from environment variables for on-prem.\n        .. code-block:: python\n\n            os.environ[\"WATSONX_URL\"] = \"https://<hostname>\"\n            os.environ[\"WATSONX_VERSION\"] = \"5.2\"\n            os.environ[\"WATSONX_USERNAME\"] = \"...\"\n            os.environ[\"WATSONX_APIKEY\"] = \"...\"\n            # Only one of api_key or password is needed\n            #os.environ[\"WATSONX_PASSWORD\"] = \"...\"\n            wxai_credentials = WxAICredentials.create_from_env()",
   "type": "object",
   "properties": {
      "url": {
         "default": "https://us-south.ml.cloud.ibm.com",
         "description": "The url for watsonx ai service",
         "examples": [
            "https://us-south.ml.cloud.ibm.com",
            "https://eu-de.ml.cloud.ibm.com",
            "https://eu-gb.ml.cloud.ibm.com",
            "https://jp-tok.ml.cloud.ibm.com",
            "https://au-syd.ml.cloud.ibm.com"
         ],
         "title": "watsonx.ai url",
         "type": "string"
      },
      "api_key": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The user api key. Required for using watsonx as a service and one of api_key or password is required for using watsonx on-prem software.",
         "strip_whitespace": true,
         "title": "Api Key"
      },
      "version": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The watsonx on-prem software version. Required for using watsonx on-prem software.",
         "title": "Version"
      },
      "username": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The user name. Required for using watsonx on-prem software.",
         "title": "User name"
      },
      "password": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The user password. One of api_key or password is required for using watsonx on-prem software.",
         "title": "Password"
      },
      "instance_id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "openshift",
         "description": "The watsonx.ai instance id. Default value is openshift.",
         "title": "Instance id"
      }
   }
}

Fields:
field api_key: ', json_schema_extra={'strip_whitespace': True})] = None

The user api key. Required for using watsonx as a service and one of api_key or password is required for using watsonx on-prem software.

field instance_id: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default='openshift', title='Instance id', description='The watsonx.ai instance id. Default value is openshift.')] = 'openshift'

The watsonx.ai instance id. Default value is openshift.

field password: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Password', description='The user password. One of api_key or password is required for using watsonx on-prem software.')] = None

The user password. One of api_key or password is required for using watsonx on-prem software.

field url: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='https://us-south.ml.cloud.ibm.com', title='watsonx.ai url', description='The url for watsonx ai service', examples=['https://us-south.ml.cloud.ibm.com', 'https://eu-de.ml.cloud.ibm.com', 'https://eu-gb.ml.cloud.ibm.com', 'https://jp-tok.ml.cloud.ibm.com', 'https://au-syd.ml.cloud.ibm.com'])] = 'https://us-south.ml.cloud.ibm.com'

The url for watsonx ai service

field username: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='User name', description='The user name. Required for using watsonx on-prem software.')] = None

The user name. Required for using watsonx on-prem software.

field version: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Version', description='The watsonx on-prem software version. Required for using watsonx on-prem software.')] = None

The watsonx on-prem software version. Required for using watsonx on-prem software.

classmethod create_from_env()
pydantic model ibm_watsonx_gov.entities.credentials.WxGovConsoleCredentials

Bases: BaseModel

This class holds the authentication credentials required to connect to the watsonx Governance Console.

Examples

  1. Create credentials manually:
    credentials = WxGovConsoleCredentials(
        url="https://governance-console.example.com",
        username="admin",
        password="securepassword",
        api_key="optional-api-key"
    )
    
  2. Create credentials using environment variables:
    import os
    
    os.environ['WXGC_URL'] = "https://governance-console.example.com"
    os.environ['WXGC_USERNAME'] = "admin"
    os.environ['WXGC_PASSWORD'] = "securepassword"
    os.environ['WXGC_API_KEY'] = "optional-api-key"  # Optional
    
    credentials = WxGovConsoleCredentials.create_from_env()
    

Show JSON schema
{
   "title": "WxGovConsoleCredentials",
   "description": "This class holds the authentication credentials required to connect to the watsonx Governance Console.\n\nExamples:\n    1. Create credentials manually:\n        .. code-block:: python\n\n            credentials = WxGovConsoleCredentials(\n                url=\"https://governance-console.example.com\",\n                username=\"admin\",\n                password=\"securepassword\",\n                api_key=\"optional-api-key\"\n            )\n\n    2. Create credentials using environment variables:\n        .. code-block:: python\n\n            import os\n\n            os.environ['WXGC_URL'] = \"https://governance-console.example.com\"\n            os.environ['WXGC_USERNAME'] = \"admin\"\n            os.environ['WXGC_PASSWORD'] = \"securepassword\"\n            os.environ['WXGC_API_KEY'] = \"optional-api-key\"  # Optional\n\n            credentials = WxGovConsoleCredentials.create_from_env()",
   "type": "object",
   "properties": {
      "url": {
         "description": "The base URL of the watsonx Governance Console.",
         "title": "Url",
         "type": "string"
      },
      "username": {
         "description": "The username used for authentication.",
         "title": "Username",
         "type": "string"
      },
      "password": {
         "description": "The password used for authentication.",
         "title": "Password",
         "type": "string"
      },
      "api_key": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Optional API key for token-based authentication.",
         "title": "Api Key"
      }
   },
   "required": [
      "url",
      "username",
      "password"
   ]
}

Fields:
field api_key: str | None = None

Optional API key for token-based authentication.

field password: str [Required]

The password used for authentication.

field url: str [Required]

The base URL of the watsonx Governance Console.

field username: str [Required]

The username used for authentication.

classmethod create_from_env()