genai.credentials module#
- pydantic model genai.credentials.Credentials[source]#
Bases:
BaseModel
The Credentials class represents credentials required for accessing the GENAI API.
- - `api_key`
API key which can be retrieved from the UI.
- - `api_endpoint`
A string representing the GENAI API endpoint (default is BAM).
- Type:
optional
Examples
Create a Credentials instance with explicit api_endpoint:
credentials = Credentials(api_key="your_api_key", api_endpoint="https://bam-api.res.ibm.com")
Create a Credentials instance with default api_endpoint:
credentials = Credentials(api_key="your_api_key")
Create a Credentials instance from environment variables:
credentials = Credentials.from_env()
- Validators:
_validate_api_endpoint
»api_endpoint
- field api_endpoint: str [Required]#
GENAI API Endpoint
- Constraints:
min_length = 1
- Validated by:
_validate_api_endpoint
- field api_key: SecretStr [Required]#
The GENAI API Key
- __init__(api_key, api_endpoint=None, **kwargs)[source]#
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
api_key (str) –
api_endpoint (str | None) –