Vex Python SDK
The reliability layer for AI agents in production. Trace executions, enforce guardrails, and monitor agent behavior — with zero changes to your agent's core logic.
Installation
pip install vex-sdk
Quick Start
from vex import Vex, VexConfig
guard = Vex(
api_key="your-api-key",
config=VexConfig(api_url="https://api.tryvex.dev"),
)
# 1. Decorator — auto-capture input/output/latency
@guard.watch(agent_id="my-agent")
def run_agent(prompt: str) -> str:
return call_llm(prompt)
# 2. Context manager — fine-grained step tracing
with guard.trace(agent_id="my-agent", task="summarize") as ctx:
result = call_llm(prompt)
ctx.step("llm", "summarize", input=prompt, output=result)
ctx.record(result)
Sync Verification
Run inline verification with pass/flag/block decisions. When the verification engine determines an output is unreliable, the SDK raises VexBlockError so your application can handle it gracefully.
from vex import Vex, VexConfig, VexBlockError
guard = Vex(
api_key="your-api-key",
config=VexConfig(
mode="sync",
api_url="https://api.tryvex.dev",
),
)
@guard.watch(agent_id="my-agent")
def run_agent(prompt: str) -> str:
return call_llm(prompt)
try:
result = run_agent("Summarize this document")
# result is a VexResult with confidence score
print(result.output, result.confidence, result.action)
except VexBlockError as e:
print(f"Blocked: confidence={e.result.confidence}")
Correction Cascade
Automatically correct unreliable outputs instead of blocking. When enabled, the verification engine attempts to fix issues and returns the corrected output.
guard = Vex(
api_key="your-api-key",
config=VexConfig(
mode="sync",
correction="cascade", # Enable correction
transparency="transparent", # Include correction details in result
),
)
result = run_agent("Summarize this document")
if result.corrected:
print(f"Output was corrected: {result.output}")
print(f"Original: {result.original_output}")
Session Tracking & Conversation History
Group related executions into sessions with automatic conversation history for multi-turn verification (hallucination, drift, coherence).
session = guard.session(agent_id="chat-bot")
# Turn 1
with session.trace(task="greeting", input_data="Hello") as ctx:
response = call_llm("Hello")
ctx.record(response)
# Turn 2 — conversation history from turn 1 is sent automatically
with session.trace(task="follow-up", input_data="Tell me more") as ctx:
response = call_llm("Tell me more")
ctx.record(response)
The session maintains a sliding window of conversation history (configurable via conversation_window_size), enabling cross-turn verification checks like self-contradiction detection and goal drift analysis.
Configuration
from vex import VexConfig
from vex.models import ThresholdConfig
VexConfig(
mode="async", # "async" (fire-and-forget) or "sync" (inline verification)
correction="none", # "none" or "cascade" (auto-correct unreliable outputs)
transparency="opaque", # "opaque" or "transparent" (include correction details)
api_url="https://api.tryvex.dev",
flush_interval_s=1.0, # Batch flush interval (async mode)
flush_batch_size=50, # Max events per flush batch
timeout_s=2.0, # HTTP timeout for API calls
conversation_window_size=10, # Max conversation turns retained per session
confidence_threshold=ThresholdConfig(
pass_threshold=0.8, # >= 0.8 → pass
flag_threshold=0.5, # >= 0.5 → flag (warning logged)
block_threshold=0.3, # < 0.3 → block (raises VexBlockError)
),
)
What's New in v0.3.0
- Rebranded to Vex:
pip install vex-sdk,from vex import Vex, VexConfig - Sync Verification: Inline pass/flag/block decisions via
mode="sync"with configurable confidence thresholds - Correction Cascade: Auto-correct unreliable outputs with
correction="cascade", dual-timeout transport (2s verify / 12s correction), and transparent/opaque modes - Conversation-Aware Verification: Multi-turn coherence, cross-turn hallucination detection, and goal drift analysis via automatic session history
VexResultModel: Structured verification results withconfidence,action,corrected,original_output, andcorrectionsfieldsVexBlockError: Exception raised when verification blocks output, with the fullVexResultattachedConversationTurnModel: First-class conversation turn representation for multi-turn agents
Requirements
- Python 3.9+
- Dependencies:
httpx,pydantic(v2)
Documentation
Full documentation: docs.tryvex.dev
License
Apache 2.0 — see LICENSE for details.
Metadata
Release files for vex-sdk 0.3.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 | Provenance | Actions |
|---|---|---|---|---|
| vex_sdk-0.3.0.tar.gz | 25.6 kB | Without provenance | Details for vex_sdk-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vex_sdk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for vex_sdk-0.3.0-py3-none-any.whl |
Total release size: 48.5 kB
Release files / vex_sdk-0.3.0.tar.gz
| Download URL | vex_sdk-0.3.0.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bbc6fa581b6c483e2aa907218339b27adf478cf509fd66e50cfb5ef421a33af
|
|
BLAKE2b-256 checksum How to use checksums |
d0a82bbdca727a34ea713fc0e44f01e1268d7eba139f203b266939465e0432be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / vex_sdk-0.3.0-py3-none-any.whl
| Download URL | vex_sdk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5744ccbe8f3f2134492bf045f602dc180d14cc8486512dd01853a8df13f759ba
|
|
BLAKE2b-256 checksum How to use checksums |
06114ffdf9876f73e90f38b8d7f21c140bdca03faa66a3540eec316f97402c12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for vex-sdk 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.