Skip to main content

Q SDK

The q-sdk is the official Python library for instrumenting AI agents with Q's security governance, policy enforcement, and telemetry tracking.

Installation

pip install q-sdk

(If installing locally for development from this repository: pip install -e .)

Quickstart

Wrap any AI agent in the QAgent class and decorate its tools.

from q_sdk import QAgent, tool, require_approval

# Initialize the agent SDK
agent = QAgent(
    name="Financial Analyst Agent",
    q_url="https://your-render-app.onrender.com",
    api_key="your_q_api_key",
    agent_type="analyst",
    framework="custom"
)

# Instrument a tool
@agent.tool(risk_level="low", data_classification="public")
def fetch_stock_price(ticker: str):
    # This call is automatically logged and policy-checked by Q
    return f"Stock price for {ticker} is $100."

# Add Human-in-the-loop (HITL) gates to high-risk tools
@agent.tool(risk_level="critical", data_classification="pii")
@require_approval(reason="Accesses customer bank accounts", timeout_seconds=300)
def wire_transfer(customer_id: str, amount: float):
    # Execution will PAUSE here until an admin approves it via the Q Dashboard!
    return f"Transferred ${amount} for {customer_id}."

Features

  • Automatic Telemetry: Tracks tool invocations, inputs, outputs, errors, and latency.
  • Client-Side Policy Cache: Evaluates tool calls against organization policies instantly with low latency.
  • Human-in-the-loop (HITL): @require_approval seamlessly pauses execution and blocks until a human administrator approves the action.
  • LLM Interception: Log token usage and model inputs using the wrap_llm_call decorator.

Architecture

The SDK communicates with the Q backend (FastAPI) via HTTP and WebSockets.

  • Registration: On startup, the SDK registers the agent and retrieves its agent_id.
  • Policy Cache: Downloads active policies on startup to perform rapid, local evaluation of tool calls.
  • Event Ingestion: Async/Sync HTTP streams of events to the backend.
  • Approvals: Pauses execution and polls/waits on a WebSocket or long-polling endpoint for administrative sign-off.

Metadata

Release files for q-agent-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for q-agent-sdk 0.1.0
File Size Uploaded Provenance Actions
q_agent_sdk-0.1.0.tar.gz 11.0 kB Without provenance Details for q_agent_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for q-agent-sdk 0.1.0
File Interpreter ABI Platform Actions
q_agent_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for q_agent_sdk-0.1.0-py3-none-any.whl

Total release size: 25.3 kB

Release files / q_agent_sdk-0.1.0.tar.gz

Download URL q_agent_sdk-0.1.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d5e550373a7011162499dca7b19a7af1f5880228f59db21a9763e2b5c940065d
BLAKE2b-256 checksum
How to use checksums
6605a6cb3e40f4971ef8b19a01dee54dad1bd8d95b37775834b1c33aee1ddac3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / q_agent_sdk-0.1.0-py3-none-any.whl

Download URL q_agent_sdk-0.1.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed11b3719d5581e923ee1e40d4bb76804b27392aa6c5a6d40be4ffe6d85c59db
BLAKE2b-256 checksum
How to use checksums
41caadcf07d1b6e1d49fecedbc327474ca39aefb000d9bc305d0af56050c6fa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for q-agent-sdk 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page