One line around chat.completions.
Wrap your OpenAI client once. Messages, tool calls, token usage — every call captured through canonicalization and signing without application code modifications.
The wrapper keeps the same surface (chat.completions.create, responses.create, beta.assistants, embeddings.create), so nothing in your application code changes except the import line.
The wrap pattern
Construct the OpenAI client as you already do — environment API key, Azure AD token provider, or custom base_url — then hand it to veridra.wrap_openaiwith a system_id that maps to a registered Govern system. The wrapper is re-entrant, streaming-aware, respects OpenAI's retry/rate-limit semantics, and propagates context (trace IDs, user IDs, deadlines) down the call stack.
from openai import OpenAI
import veridra
client = OpenAI() # or AzureOpenAI(...)
wrapped = veridra.wrap_openai(client, system_id="loan-underwriter-v3")
resp = wrapped.chat.completions.create(
model="gpt-4o-2024-08-06",
messages=[{"role": "user", "content": "..."}],
)What Veridra captures
Request payload
Full canonicalized chat/responses payload — messages, tools, response_format, temperature, seed, user id. Captured pre-redaction to enable PII policy evaluation. Redacted copies follow Govern policy requirements.
Model and routing metadata
Model slug (gpt-4o-2024-08-06, o1-preview), deployment region for Azure OpenAI, system_fingerprint, and OpenAI request ID. Enough to trace an incident to a specific model build.
Response and tool calls
Completion content, tool-call arguments, finish_reason. Refusal content and structured-output JSON included. Streaming responses captured post-aggregation.
Usage and cost
prompt_tokens, completion_tokens, cached_tokens, and reasoning_tokens for o-series models. Supports cost allocation and rate-limit incident anchoring.
What you get
- Zero changes to prompts, tool schemas, or response handling.
- Works with OpenAI, Azure OpenAI, and OpenAI-compatible endpoints (vLLM, Together, Groq).
- Policy failures raise typed exceptions before model output reaches your code.
- Opt-in request/response redaction via Govern policies, evaluated per call.
- Compatible with LangChain, LlamaIndex, and Vercel AI SDK.