Wisent

raw JSON →
0.11.6 verified Mon Apr 27 auth: no python

Wisent (version 0.11.6) is a Python library to monitor, log, and influence AI model outputs in real-time. It provides a lightweight agent for tracing LLM calls and injecting interventions such as content moderation, jailbreak detection, and custom logic. Released on a monthly cadence.

pip install wisent
error WisentError: No API key found. Set WISENT_API_KEY environment variable.
cause Missing or unset API key.
fix
Export WISENT_API_KEY or pass api_key to Wisent() constructor.
error TypeError: openai_trace() got an unexpected keyword argument 'guard'
cause Using old 'guard' parameter instead of new 'guards'.
fix
Change guard=MyGuard() to guards=[MyGuard()].
error ModuleNotFoundError: No module named 'wisent.guard'
cause Trying to import from submodule that no longer exists.
fix
Import directly: from wisent import WisentGuard.
error AttributeError: 'Wisent' object has no attribute 'start_trace'
cause Method renamed or removed in recent versions.
fix
Use the @openai_trace decorator or with wis.trace(): context manager.
breaking API key must be set via environment variable or constructor; not reading from config files.
fix Set WISENT_API_KEY environment variable or pass api_key='your_key' to Wisent().
breaking The @openai_trace decorator changed signature in v0.11.0. Old 'guard' parameter is now 'guards' (list).
fix Use `@openai_trace(wis, guards=[MyGuard()])` instead of `@openai_trace(wis, guard=MyGuard())`.
deprecated The method `add_guard` is deprecated; use the `guards` parameter in the trace decorator.
fix Pass guards to @openai_trace(wis, guards=[...]).
gotcha Wisent only supports OpenAI and Anthropic providers; other LLMs require custom instrumentation.
fix Use the generic `@trace` decorator for custom providers.

Basic example: initialize Wisent, decorate an OpenAI call to trace it.

from wisent import Wisent
from wisent.trace import openai_trace

import os

# Initialize Wisent (requires WISENT_API_KEY env var)
wis = Wisent(api_key=os.environ.get('WISENT_API_KEY', ''))

# Trace OpenAI calls
@openai_trace(wis)
def generate(prompt: str):
    import openai
    response = openai.ChatCompletion.create(
        model='gpt-3.5-turbo',
        messages=[{'role': 'user', 'content': prompt}]
    )
    return response['choices'][0]['message']['content']

# Run
print(generate('Say hello!'))