Skip to main content
QWED Open Responses provides a verified wrapper for the OpenAI SDK.

Installation


Quick start

Always pass at least one guard. VerifiedOpenAI without guards emits a UserWarning at construction: verification is fail-closed, so with zero guards every response fails verification and either raises ResponseBlocked (block_on_failure=True) or is returned unverified (block_on_failure=False).
The attached _qwed_verification result also exposes:
  • warnings: guard results that passed with warning severity
  • request_id: correlation ID when a request_id was supplied in the verification context
  • binding and verify_binding(): tamper-evidence tying the result to the exact response and guard list
  • timestamp: timezone-aware UTC timestamp with the +00:00 offset
See the guards reference for details.

Structured outputs

Keep SchemaGuard out of the client’s guards. It validates the whole response object (id, choices, usage and so on) rather than the model’s JSON, so every response fails with “Schema validation failed”. Parse the model’s JSON and check it as above.

Tool calling verification


Handling blocked responses


Non-blocking mode


Budget limits with verification context

Pass verification_context to chat.completions.create() or responses.create() to give guards trusted usage totals, such as the running total_cost and total_tokens for a session. VerifiedOpenAI removes verification_context from the request before calling OpenAI, so it never reaches the API. The context is then passed to every guard when the response is verified.
You can also call client.verify(response, context={...}) directly.

Responses API (preview)

client.responses.create(...) runs the same guards on Responses API objects. From v0.6.2, ToolGuard checks each call item in the response’s output[] the way it checks a single call. A function_call, custom_tool_call or mcp_approval_request is checked under its own name. A client action item (local_shell_call, shell_call, apply_patch_call, computer_call) is checked as its action tool, which the default blocklist blocks. The blocklist, allowlist and argument patterns apply to each call, and in Python so do custom validators and max_calls_per_response. Unknown *_call and *_request items fail closed, and so do remote MCP mcp_call items that carry a name and arguments, as the API returns them. An mcp_call without arguments reads as tool-free. Text and the provider-hosted web_search_call, file_search_call, code_interpreter_call and image_generation_call items pass. The provider has already run those hosted tools by the time the response arrives, and ToolGuard doesn’t check them, so allowed_tools and blocked_tools can’t stop them. Limit hosted tools in the tools you send with the request.
In v0.6.1, ToolGuard didn’t read call items in output[]. Every response with a function call raised ResponseBlocked, even a safe one. Upgrade to v0.6.2 to use your own function tools with responses.create.

Full example