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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

q_agent_sdk-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

q_agent_sdk-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file q_agent_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: q_agent_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for q_agent_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5e550373a7011162499dca7b19a7af1f5880228f59db21a9763e2b5c940065d
MD5 515477cfcd3f80658ff45e426ca9463c
BLAKE2b-256 6605a6cb3e40f4971ef8b19a01dee54dad1bd8d95b37775834b1c33aee1ddac3

See more details on using hashes here.

File details

Details for the file q_agent_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: q_agent_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for q_agent_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed11b3719d5581e923ee1e40d4bb76804b27392aa6c5a6d40be4ffe6d85c59db
MD5 d1a206bc6435fd78b8d09dd5a84b55d0
BLAKE2b-256 41caadcf07d1b6e1d49fecedbc327474ca39aefb000d9bc305d0af56050c6fa6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page