Welcome to Trustwise SDK’s documentation!

Trustwise SDK is a powerful tool for evaluating AI-generated content with Trustwise’s unified Metrics API.

Quickstart

  1. Install the SDK:

    pip install trustwise
    
  2. Set up and run your first evaluation:

    import os
    from trustwise.sdk import TrustwiseSDK
    from trustwise.sdk.config import TrustwiseConfig
    
    # Initialize the SDK
    config = TrustwiseConfig(api_key=os.environ["TW_API_KEY"])
    trustwise = TrustwiseSDK(config)
    
    # Evaluate faithfulness
    trustwise.metrics.faithfulness.evaluate(
        query="What is the capital of France?",
        response="The capital of France is Paris.",
        context=[{"chunk_text": "Paris is the capital of France.", "chunk_id": "doc:idx:1"}]
    )
    

    Note

    All metrics are available in both synchronous and asynchronous forms. For async, use TrustwiseSDKAsync and await the evaluate() methods.

Documentation Overview

This documentation is organized to help you quickly find what you need:

  • Usage: Get started with basic setup, configuration, and comprehensive examples (Usage)

  • Metrics: Latest v4 metrics with enhanced type safety and improved response structures (V4 Metrics)

  • Legacy V3: Deprecated v3 metrics (only cost available - see Migration Guide: v3 to v4) (V3 Metrics)

  • API Reference: Full technical documentation for all SDK features and metrics (API Reference)

  • API Versioning: Use explicit or default API versions for flexibility (API Versioning)

  • Migration Guide: Step-by-step guide to migrate from v3 to v4 (Migration Guide: v3 to v4)

  • Changelog: Track documentation changes and feature additions (Changelog)

Indices and tables