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.0
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.0.tar.gz | 15.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| verexa-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.2 kB
Release files / verexa-0.1.0.tar.gz
| Download URL | verexa-0.1.0.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5105dbf214b13ede90d8f413e7abae4be3e6197e8e180f2d10f95b42bfd3b4ca
|
|
BLAKE2b-256 checksum How to use checksums |
f688d4c8af53e77e6683dc9a002d7cbdbc7ccef0655342006101357176530927
|
| 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.0-py3-none-any.whl
| Download URL | verexa-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c73c19619d21ac23c3f3597cb908587eeed977e9a699e87f0a6fb569d47dd65
|
|
BLAKE2b-256 checksum How to use checksums |
a80df231901442f35de1aa8be9bfdd38d7fd4d179ee5a00f4c1bf97763dc9932
|
| 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}
|