Skip to main content

API Reference

TurnWiseClient

Main client for interacting with TurnWise.

Constructor

Parameters:
  • turnwise_api_key (str): Your TurnWise API key
  • openrouter_api_key (str): Your OpenRouter API key
  • turnwise_base_url (Optional[str]): Custom base URL (defaults to production)
  • default_model (str): Default model for evaluations

Methods

verify()

Verify API key and connection.

list_datasets()

List all datasets for the authenticated user.

get_conversations(dataset_id)

Get all conversations for a dataset.

get_pipelines(dataset_id)

Get all evaluation pipelines for a dataset.

register_metric(dataset_id, metric)

Register a metric in TurnWise.

evaluate(dataset_id, metric, …)

Run evaluation on a dataset.
Parameters:
  • dataset_id (int): Dataset ID to evaluate
  • metric (Metric): Metric definition
  • max_concurrent (int): Maximum concurrent evaluations
  • auto_sync (bool): Automatically sync results to TurnWise
  • progress_callback (Optional[Callable]): Progress callback function
Returns: List[EvaluationResult]

sync_results(results)

Manually sync evaluation results to TurnWise.

close()

Close the client and cleanup resources.

Metric

Definition of an evaluation metric.

Constructor

Parameters:
  • name (str): Metric name
  • prompt (str): Evaluation prompt (supports @VARIABLE syntax)
  • evaluation_level (EvaluationLevel): Level to evaluate at
  • output_type (OutputType): Type of output
  • description (Optional[str]): Metric description
  • output_schema (Optional[Dict]): JSON schema for JSON output type
  • model_name (Optional[str]): Model to use (overrides default)
  • aggregate_results (bool): Aggregate step results to message level
  • node_id (Optional[int]): Existing node ID (for reusing metrics)
  • pipeline_id (Optional[int]): Pipeline ID (for reusing metrics)

EvaluationLevel

Enumeration of evaluation levels.

OutputType

Enumeration of output types.

EvaluationResult

Result of an evaluation.

Properties

  • entity_id (int): ID of evaluated entity
  • entity_type (str): Type of entity (“conversation”, “message”, “step”)
  • result (Any): Raw evaluation result
  • metadata (Dict): Additional metadata

Methods

get_score()

Extract score from result.

EvaluationOrchestrator

Lower-level orchestrator for manual evaluation control.

Constructor

Parameters:
  • llm_provider (LLMProvider): LLM provider instance
  • default_model (str): Default model name
  • extract_goals (bool): Whether to extract goals from conversations

Methods

evaluate_conversation(conversation, metric)

Evaluate a single conversation.

OpenRouterProvider

LLM provider for OpenRouter API.

Constructor

Models

Dataset

Conversation

Message

Step

Utility Functions

setup_logging()

Configure logging for the SDK.

Error Handling

TurnWiseAPIError

Exception raised for TurnWise API errors.

Next Steps

Basic Usage

Learn how to use the SDK

Advanced Usage

Explore advanced features