Credentials¶
- pydantic model ibm_watsonx_gov.entities.credentials.AWSBedrockCredentials¶
Bases:
BaseModel
Defines the AWSBedrockCredentials class for accessing AWS Bedrock using environment variables or manual input.
Examples
- Create credentials manually:
credentials = AWSBedrockCredentials( aws_access_key_id="your-access-key-id", aws_secret_access_key="your-secret-access-key", aws_region_name="us-east-1", aws_session_token="optional-session-token" )
- Create credentials from environment:
os.environ["AWS_ACCESS_KEY_ID"] = "your-access-key-id" os.environ["AWS_DEFAULT_REGION"] = "us-east-1" os.environ["AWS_SECRET_ACCESS_KEY"] = "your-secret-access-key" credentials = AWSBedrockCredentials.create_from_env()
Show JSON schema
{ "title": "AWSBedrockCredentials", "description": "Defines the AWSBedrockCredentials class for accessing AWS Bedrock using environment variables or manual input.\n\nExamples:\n 1. Create credentials manually:\n .. code-block:: python\n\n credentials = AWSBedrockCredentials(\n aws_access_key_id=\"your-access-key-id\",\n aws_secret_access_key=\"your-secret-access-key\",\n aws_region_name=\"us-east-1\",\n aws_session_token=\"optional-session-token\"\n )\n\n 2. Create credentials from environment:\n .. code-block:: python\n\n os.environ[\"AWS_ACCESS_KEY_ID\"] = \"your-access-key-id\"\n os.environ[\"AWS_DEFAULT_REGION\"] = \"us-east-1\"\n os.environ[\"AWS_SECRET_ACCESS_KEY\"] = \"your-secret-access-key\"\n\n credentials = AWSBedrockCredentials.create_from_env()", "type": "object", "properties": { "aws_access_key_id": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "The AWS access key id. This attribute value will be read from AWS_ACCESS_KEY_ID environment variable when creating AWSBedrockCredentials from environment.", "title": "AWS Access Key ID" }, "aws_secret_access_key": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "The AWS secret access key. This attribute value will be read from AWS_SECRET_ACCESS_KEY environment variable when creating AWSBedrockCredentials from environment.", "title": "AWS Secret Access Key" }, "aws_region_name": { "default": "us-east-1", "description": "AWS region. This attribute value will be read from AWS_DEFAULT_REGION environment variable when creating AWSBedrockCredentials from environment.", "examples": [ "us-east-1", "eu-west-1" ], "title": "AWS Region", "type": "string" }, "aws_session_token": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "Optional AWS session token for temporary credentials.", "title": "AWS Session Token" } }, "required": [ "aws_access_key_id", "aws_secret_access_key", "aws_session_token" ] }
- Fields:
- Validators:
validate_credentials
»all fields
- field aws_access_key_id: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, title='AWS Access Key ID', description='The AWS access key id. This attribute value will be read from AWS_ACCESS_KEY_ID environment variable when creating AWSBedrockCredentials from environment.')] [Required]¶
The AWS access key id. This attribute value will be read from AWS_ACCESS_KEY_ID environment variable when creating AWSBedrockCredentials from environment.
- Validated by:
- field aws_region_name: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='us-east-1', title='AWS Region', description='AWS region. This attribute value will be read from AWS_DEFAULT_REGION environment variable when creating AWSBedrockCredentials from environment.', examples=['us-east-1', 'eu-west-1'])] = 'us-east-1'¶
AWS region. This attribute value will be read from AWS_DEFAULT_REGION environment variable when creating AWSBedrockCredentials from environment.
- Validated by:
- field aws_secret_access_key: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, title='AWS Secret Access Key', description='The AWS secret access key. This attribute value will be read from AWS_SECRET_ACCESS_KEY environment variable when creating AWSBedrockCredentials from environment.')] [Required]¶
The AWS secret access key. This attribute value will be read from AWS_SECRET_ACCESS_KEY environment variable when creating AWSBedrockCredentials from environment.
- Validated by:
- field aws_session_token: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, title='AWS Session Token', description='Optional AWS session token for temporary credentials.')] [Required]¶
Optional AWS session token for temporary credentials.
- Validated by:
- classmethod create_from_env()¶
- validator validate_credentials » all fields¶
- 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" ] }
- 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" }, "token": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "The bearer token.", "title": "Token" }, "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" }, "scope_id": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "The scope identifier.", "title": "Scope ID" }, "scope_collection_type": { "anyOf": [ { "enum": [ "accounts", "subscriptions", "services", "products", "externalservices" ], "type": "string" }, { "type": "null" } ], "default": null, "description": "Scope collection type of item(s).", "title": "Scope Collection Type" } } }
- Fields:
- Validators:
validate_credentials
»all 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.
- 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 scope_collection_type: Annotated[Literal['accounts', 'subscriptions', 'services', 'products', 'externalservices'] | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Scope Collection Type', description='Scope collection type of item(s).')] = None¶
Scope collection type of item(s).
- Validated by:
- field scope_id: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Scope ID', description='The scope identifier.')] = None¶
The scope identifier.
- 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 token: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, title='Token', description='The bearer token.')] = None¶
The bearer token.
- 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.GoogleAIStudioCredentials¶
Bases:
BaseModel
Defines the GoogleAIStudioCredentials class for accessing Google AI Studio using an API key.
Examples
- Create credentials manually:
google_credentials = GoogleAIStudioCredentials(api_key="your-api-key")
- Create credentials from environment:
os.environ["GOOGLE_API_KEY"] = "your-api-key" google_credentials = GoogleAIStudioCredentials.create_from_env()
Show JSON schema
{ "title": "GoogleAIStudioCredentials", "description": "Defines the GoogleAIStudioCredentials class for accessing Google AI Studio using an API key.\n\nExamples:\n 1. Create credentials manually:\n .. code-block:: python\n\n google_credentials = GoogleAIStudioCredentials(api_key=\"your-api-key\")\n\n 2. Create credentials from environment:\n .. code-block:: python\n\n os.environ[\"GOOGLE_API_KEY\"] = \"your-api-key\"\n google_credentials = GoogleAIStudioCredentials.create_from_env()", "type": "object", "properties": { "api_key": { "description": "The Google AI Studio key. This attribute can be read from GOOGLE_API_KEY environment variable when creating GoogleAIStudioCredentials from environment.", "title": "Api Key", "type": "string" } }, "required": [ "api_key" ] }
- Fields:
- Validators:
validate_credentials
»all fields
- field api_key: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Api Key', description='The Google AI Studio key. This attribute can be read from GOOGLE_API_KEY environment variable when creating GoogleAIStudioCredentials from environment.')] [Required]¶
The Google AI Studio key. This attribute can be read from GOOGLE_API_KEY environment variable when creating GoogleAIStudioCredentials from environment.
- 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
- Create OpenAICredentials with default parameters. By default Dallas region is used.
openai_credentials = OpenAICredentials(api_key=api_key, url=openai_url)
- 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.PortKeyCredentials¶
Bases:
BaseModel
Defines the PortKeyCredentials class to specify the PortKey Gateway details.
Examples
- Create PortKeyCredentials with default parameters.
portkey_credentials = PortKeyCredentials(api_key=api_key, url=portkey_url, provider_api_key=provider_api_key, provider=provider_name)
- Create PortKeyCredentials by reading from environment variables.
os.environ["PORTKEY_API_KEY"] = "..." os.environ["PORTKEY_URL"] = "..." os.environ["PORTKEY_PROVIDER_API_KEY"] = "..." os.environ["PORTKEY_PROVIDER_NAME"] = "..." portkey_credentials = PortKeyCredentials.create_from_env()
Show JSON schema
{ "title": "PortKeyCredentials", "description": "Defines the PortKeyCredentials class to specify the PortKey Gateway details.\n\nExamples:\n 1. Create PortKeyCredentials with default parameters.\n .. code-block:: python\n\n portkey_credentials = PortKeyCredentials(api_key=api_key,\n url=portkey_url,\n provider_api_key=provider_api_key,\n provider=provider_name)\n\n 2. Create PortKeyCredentials by reading from environment variables.\n .. code-block:: python\n\n os.environ[\"PORTKEY_API_KEY\"] = \"...\"\n os.environ[\"PORTKEY_URL\"] = \"...\"\n os.environ[\"PORTKEY_PROVIDER_API_KEY\"] = \"...\"\n os.environ[\"PORTKEY_PROVIDER_NAME\"] = \"...\"\n portkey_credentials = PortKeyCredentials.create_from_env()", "type": "object", "properties": { "url": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "PortKey url. This attribute can be read from `PORTKEY_URL` environment variable.", "title": "Url" }, "api_key": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "API key for PortKey. This attribute can be read from `PORTKEY_API_KEY` environment variable.", "title": "Api Key" }, "provider_api_key": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "API key for the provider. This attribute can be read from `PORTKEY_PROVIDER_API_KEY` environment variable.", "title": "Provider Api Key" }, "provider": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "description": "The provider name. This attribute can be read from `PORTKEY_PROVIDER_NAME` environment variable.", "title": "Provider" } }, "required": [ "url", "api_key", "provider_api_key", "provider" ] }
- field api_key: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, description='API key for PortKey. This attribute can be read from `PORTKEY_API_KEY` environment variable.')] [Required]¶
API key for PortKey. This attribute can be read from PORTKEY_API_KEY environment variable.
- field provider: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, description='The provider name. This attribute can be read from `PORTKEY_PROVIDER_NAME` environment variable.')] [Required]¶
The provider name. This attribute can be read from PORTKEY_PROVIDER_NAME environment variable.
- field provider_api_key: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, description='API key for the provider. This attribute can be read from `PORTKEY_PROVIDER_API_KEY` environment variable.')] [Required]¶
API key for the provider. This attribute can be read from PORTKEY_PROVIDER_API_KEY environment variable.
- field url: Annotated[str | None, FieldInfo(annotation=NoneType, required=True, description='PortKey url. This attribute can be read from `PORTKEY_URL` environment variable.')] [Required]¶
PortKey url. This attribute can be read from PORTKEY_URL environment variable.
- 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.VertexAICredentials¶
Bases:
BaseModel
Defines the VertexAICredentials class for accessing Vertex AI using service account credentials.
Examples
- Create credentials manually:
vertex_credentials = VertexAICredentials( credentials_path="path/to/service_account.json", project_id="my-gcp-project", location="us-central1" )
- Create credentials from environment:
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/service_account.json" os.environ["GOOGLE_CLOUD_PROJECT"] = "my-gcp-project" os.environ["GOOGLE_CLOUD_LOCATION"] = "us-central1" vertex_ai_credentials = VertexAICredentials.create_from_env()
Show JSON schema
{ "title": "VertexAICredentials", "description": "Defines the VertexAICredentials class for accessing Vertex AI using service account credentials.\n\nExamples:\n 1. Create credentials manually:\n .. code-block:: python\n\n vertex_credentials = VertexAICredentials(\n credentials_path=\"path/to/service_account.json\",\n project_id=\"my-gcp-project\",\n location=\"us-central1\"\n )\n\n 2. Create credentials from environment:\n .. code-block:: python\n\n os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = \"path/to/service_account.json\"\n os.environ[\"GOOGLE_CLOUD_PROJECT\"] = \"my-gcp-project\"\n os.environ[\"GOOGLE_CLOUD_LOCATION\"] = \"us-central1\"\n\n vertex_ai_credentials = VertexAICredentials.create_from_env()", "type": "object", "properties": { "credentials_path": { "description": "Path to service-account JSON. This attribute can be read from GOOGLE_APPLICATION_CREDENTIALS environment variable when creating VertexAICredentials from environment.", "title": "Credentials Path", "type": "string" }, "project_id": { "description": "The Google Cloud project id. This attribute can be read from GOOGLE_CLOUD_PROJECT or GCLOUD_PROJECT environment variable when creating VertexAICredentials from environment.", "title": "Project ID", "type": "string" }, "location": { "default": "us-central1", "description": "Vertex AI region. This attribute can be read from GOOGLE_CLOUD_LOCATION environment variable when creating VertexAICredentials from environment. By default us-central1 location is used.", "examples": [ "us-central1", "europe-west4" ], "title": "Location", "type": "string" } }, "required": [ "credentials_path", "project_id" ] }
- Fields:
- Validators:
validate_credentials
»all fields
- field credentials_path: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Credentials Path', description='Path to service-account JSON. This attribute can be read from GOOGLE_APPLICATION_CREDENTIALS environment variable when creating VertexAICredentials from environment.')] [Required]¶
Path to service-account JSON. This attribute can be read from GOOGLE_APPLICATION_CREDENTIALS environment variable when creating VertexAICredentials from environment.
- Validated by:
- field location: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='us-central1', title='Location', description='Vertex AI region. This attribute can be read from GOOGLE_CLOUD_LOCATION environment variable when creating VertexAICredentials from environment. By default us-central1 location is used.', examples=['us-central1', 'europe-west4'])] = 'us-central1'¶
Vertex AI region. This attribute can be read from GOOGLE_CLOUD_LOCATION environment variable when creating VertexAICredentials from environment. By default us-central1 location is used.
- Validated by:
- field project_id: Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Project ID', description='The Google Cloud project id. This attribute can be read from GOOGLE_CLOUD_PROJECT or GCLOUD_PROJECT environment variable when creating VertexAICredentials from environment.')] [Required]¶
The Google Cloud project id. This attribute can be read from GOOGLE_CLOUD_PROJECT or GCLOUD_PROJECT environment variable when creating VertexAICredentials from environment.
- Validated by:
- classmethod create_from_env()¶
- validator validate_credentials » all fields¶
- pydantic model ibm_watsonx_gov.entities.credentials.WxAICredentials¶
Bases:
BaseModel
Defines the WxAICredentials class to specify the watsonx.ai server details.
Examples
- Create WxAICredentials with default parameters. By default Dallas region is used.
wxai_credentials = WxAICredentials(api_key="...")
- Create WxAICredentials by specifying region url.
wxai_credentials = WxAICredentials(api_key="...", url="https://au-syd.ml.cloud.ibm.com")
- 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()
- Create WxAICredentials for on-prem.
wxai_credentials = WxAICredentials(url="https://<hostname>", username="..." api_key="...", version="5.2")
- 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
- Create credentials manually:
credentials = WxGovConsoleCredentials( url="https://governance-console.example.com", username="admin", password="securepassword", api_key="optional-api-key" )
- 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" ] }
- 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()¶