{"id":22987,"library":"wisent","title":"Wisent","description":"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.","status":"active","version":"0.11.6","language":"python","source_language":"en","source_url":"https://github.com/wisent-ai/wisent","tags":["ai","monitoring","llm","trace","guardrails","openai","anthropic"],"install":[{"cmd":"pip install wisent","lang":"bash","label":"Latest from PyPI"}],"dependencies":[],"imports":[{"note":"Common mistake: importing the module directly, but the main class is `Wisent`.","wrong":"import wisent","symbol":"Wisent","correct":"from wisent import Wisent"},{"note":"In older versions, guards were in a submodule; now they are at the top level.","wrong":"from wisent.guard import WisentGuard","symbol":"WisentGuard","correct":"from wisent import WisentGuard"}],"quickstart":{"code":"from wisent import Wisent\nfrom wisent.trace import openai_trace\n\nimport os\n\n# Initialize Wisent (requires WISENT_API_KEY env var)\nwis = Wisent(api_key=os.environ.get('WISENT_API_KEY', ''))\n\n# Trace OpenAI calls\n@openai_trace(wis)\ndef generate(prompt: str):\n    import openai\n    response = openai.ChatCompletion.create(\n        model='gpt-3.5-turbo',\n        messages=[{'role': 'user', 'content': prompt}]\n    )\n    return response['choices'][0]['message']['content']\n\n# Run\nprint(generate('Say hello!'))","lang":"python","description":"Basic example: initialize Wisent, decorate an OpenAI call to trace it."},"warnings":[{"fix":"Set WISENT_API_KEY environment variable or pass api_key='your_key' to Wisent().","message":"API key must be set via environment variable or constructor; not reading from config files.","severity":"breaking","affected_versions":">=0.11.0"},{"fix":"Use `@openai_trace(wis, guards=[MyGuard()])` instead of `@openai_trace(wis, guard=MyGuard())`.","message":"The @openai_trace decorator changed signature in v0.11.0. Old 'guard' parameter is now 'guards' (list).","severity":"breaking","affected_versions":">=0.11.0"},{"fix":"Pass guards to @openai_trace(wis, guards=[...]).","message":"The method `add_guard` is deprecated; use the `guards` parameter in the trace decorator.","severity":"deprecated","affected_versions":">=0.10.0 <0.12.0"},{"fix":"Use the generic `@trace` decorator for custom providers.","message":"Wisent only supports OpenAI and Anthropic providers; other LLMs require custom instrumentation.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Export WISENT_API_KEY or pass api_key to Wisent() constructor.","cause":"Missing or unset API key.","error":"WisentError: No API key found. Set WISENT_API_KEY environment variable."},{"fix":"Change `guard=MyGuard()` to `guards=[MyGuard()]`.","cause":"Using old 'guard' parameter instead of new 'guards'.","error":"TypeError: openai_trace() got an unexpected keyword argument 'guard'"},{"fix":"Import directly: `from wisent import WisentGuard`.","cause":"Trying to import from submodule that no longer exists.","error":"ModuleNotFoundError: No module named 'wisent.guard'"},{"fix":"Use the `@openai_trace` decorator or `with wis.trace():` context manager.","cause":"Method renamed or removed in recent versions.","error":"AttributeError: 'Wisent' object has no attribute 'start_trace'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}