Skip to main content

Installation & Setup

Prerequisites

  • Python 3.10 or higher
  • TurnWise account with API key
  • OpenRouter API key (or other supported LLM provider)

Installation

Install the SDK using pip:
Or with poetry:

Getting Your API Keys

TurnWise API Key

  1. Log in to TurnWise
  2. Go to SettingsAPI Keys
  3. Click “Create API Key”
  4. Copy your API key (starts with tw_)

OpenRouter API Key

  1. Sign up at OpenRouter
  2. Go to Keys page
  3. Create a new API key
  4. Copy your API key (starts with sk-or-)

Configuration

Set your API keys as environment variables:
Then initialize the client without passing keys:

Direct Configuration

Pass keys directly when creating the client:

Configuration File

Create a .env file in your project root:
Then load it:

Verify Installation

Test your setup:

Optional Configuration

Custom Base URL

For self-hosted instances or testing:

Default Model

Set a default model for all evaluations:

Troubleshooting

Import Errors

If you get import errors, ensure you’re using Python 3.10+:

Authentication Errors

If you see authentication errors:
  1. Verify your API keys are correct
  2. Check that keys are set in environment variables
  3. Ensure keys haven’t expired or been revoked

Connection Errors

If you can’t connect to TurnWise:
  1. Check your internet connection
  2. Verify the base URL is correct
  3. Check if TurnWise is experiencing downtime

Next Steps

Basic Usage

Run your first evaluation

API Reference

Explore the full API