verexa (Python)
Checks every prompt and model response against your Verexa policy before it reaches the model or the user. The Python counterpart of @verexa/sdk, with the same wire format and failure behaviour.
Python 3.10+. No runtime dependencies.
pip install verexa
Create a key in the dashboard under Settings → API keys and set it in the environment:
VEREXA_API_KEY=vx_live_...
VEREXA_BASE_URL is optional and defaults to https://api.verexa.dev. Set it to use a local or self-hosted verdict-api.
OpenAI
from openai import OpenAI
from verexa import wrap_openai
client = wrap_openai(OpenAI())
Works the same with AsyncOpenAI. Every chat.completions.create and responses.create call is now checked on both sides of the turn. A blocked input raises GuardBlockedError before the provider is called; a redacted input reaches the model with the sensitive span removed.
Manual
from verexa import create_guard
guard = create_guard()
verdict = guard.check_input(user_message, trace_id=trace_id, profile="balanced")
if verdict.action == "block":
return
reply = model(verdict.text if verdict.action == "redact" else user_message)
checked = guard.check_output(reply, trace_id=trace_id, system_prompt=SYSTEM_PROMPT)
if checked.action == "block":
return
send(checked.text if checked.action == "redact" else reply)
In async code use await guard.check_input_async(...) and await guard.check_output_async(...).
Behaviour worth knowing
- Fails open by default. If the service is unreachable the SDK returns
allowwithdegraded=True, and a circuit breaker stops hammering it. Passfail_mode="closed"to block instead. - One trace id per turn. The input check and the output check share it, so the dashboard shows them as one trace.
- Streaming is checked after the fact. Chunks have already reached the caller by the time the reply is complete, so a blocking verdict raises once the stream ends. It is a retraction signal, not a gate.
- Profiles.
deterministic(pattern detectors only, no model calls),balanced(adds the tier-2 classifier, and the tier-3 judge on anything they do not call clean),audit(the judge reviews every check; pass a largertimeout_ms, e.g.15000). A check that names no profile uses the project's default from the dashboard, and that is whatwrap_openaisends. - Only
createis wrapped. Thestream()andparse()helpers andwith_raw_responsebypass the guard; check those turns withcheck_input/check_output.
Development
cd packages/sdk-python
uv sync
uv run ruff check . && uv run ruff format --check . && uv run mypy src tests
uv run pytest
# against a real verdict-api
LIVE_VEREXA_API_KEY=<key> LIVE_VEREXA_BASE_URL=http://localhost:8080 uv run pytest -m live
Metadata
Release files for verexa 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| verexa-0.1.1.tar.gz | 15.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| verexa-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.7 kB
Release files / verexa-0.1.1.tar.gz
| Download URL | verexa-0.1.1.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6768d69be5b8e5ce3f469951b8e1b55714a93306fafa56480f10ed448639751
|
|
BLAKE2b-256 checksum How to use checksums |
e91a17bb25232ba720c81b407ed12a44a8e33de1920bdf233e1bf412fa6b6a68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Zorin OS","version":"18","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / verexa-0.1.1-py3-none-any.whl
| Download URL | verexa-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a075cc823b7d1d67efe28cabf5bb33f962edc52f62c0cae3b39986d3f681d7d1
|
|
BLAKE2b-256 checksum How to use checksums |
d37d25ab7839896e8f6d28df2dd928628e8990dd8c4ddd5fe35c8843e86165af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Zorin OS","version":"18","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|