WhyLabs API Client

0.6.16 · maintenance · verified Thu Apr 16

The `whylabs-client` is a Python client library that provides a convenient way to interact with the WhyLabs API for end-to-end AI observability. It enables users to manage models, datasets, and monitors on the WhyLabs Platform. The library is automatically generated by the OpenAPI Generator project. Current version is 0.6.16.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the WhyLabs API client with an API key. It uses environment variables for secure credential management and sets up the basic `Configuration` and `ApiClient` objects. Replace `api_key_api` with the specific API module you intend to use (e.g., `dataset_profile_api`, `data_api`). Ensure your `WHYLABS_API_KEY` is set as an environment variable.

import os
import whylabs_client
from whylabs_client.api import api_key_api

# Configure API key authorization
configuration = whylabs_client.Configuration(
    host="https://api.whylabsapp.com"
)
configuration.api_key['ApiKeyAuth'] = os.environ.get('WHYLABS_API_KEY', '')

# It's good practice to set discard_unknown_keys to True if you encounter parsing issues
# configuration.discard_unknown_keys = True

try:
    with whylabs_client.ApiClient(configuration) as api_client:
        # Create an instance of the API class
        api_instance = api_key_api.ApiKeyApi(api_client)

        # Example: List user API keys (requires appropriate permissions)
        # This call might not be available or might require specific permissions/parameters
        # depending on your API key scope. This is illustrative.
        # response = api_instance.list_user_api_keys()
        # print(response)
        print("Successfully configured WhyLabs API client.")
        print("Ensure WHYLABS_API_KEY environment variable is set for actual API calls.")

except whylabs_client.ApiException as e:
    print(f"Exception when calling WhyLabs API: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →