Skip to main content

Vix11 SDK - AI Agent Security Platform. KYA passports, 11-layer abuse detection, Agent Trust Score.

Project description

Vix11 Python SDK

Official Python SDK for the Vix11 AI agent security platform. Provides synchronous and asynchronous clients, plus ASGI middleware for FastAPI and Starlette.

Installation

pip install vix11

Requires Python 3.10+. The SDK depends on httpx for HTTP transport.

Quick Start

from vix11 import Vix11Client

client = Vix11Client(
    base_url="https://vix11.example.com",
    agent_id="my-agent",
    api_key="your-api-key",
)

result = client.detect(endpoint="/api/chat", payload='{"prompt": "hello"}')

if result.action == "block":
    print("Request blocked")
else:
    print("Request allowed")

client.close()

Async Client

For async applications, use AsyncVix11Client:

from vix11 import AsyncVix11Client

async def main():
    client = AsyncVix11Client(
        base_url="https://vix11.example.com",
        agent_id="my-agent",
        api_key="your-api-key",
    )

    result = await client.detect(endpoint="/api/chat", payload='{"prompt": "hello"}')
    print(result.action)

    await client.close()

FastAPI Middleware

The SDK includes ASGI middleware that intercepts every HTTP request, runs it through the Vix11 detection pipeline, and blocks or throttles suspicious traffic automatically.

from fastapi import FastAPI
from vix11 import AsyncVix11Client
from vix11.middleware import Vix11Middleware

app = FastAPI()

client = AsyncVix11Client(
    base_url="https://vix11.example.com",
    agent_id="my-agent",
    api_key="your-api-key",
)

app.add_middleware(Vix11Middleware, client=client)

@app.post("/api/chat")
async def chat():
    return {"reply": "Hello!"}

Middleware behavior:

  • block action: responds with 403 and a JSON error body.
  • throttle action: responds with 429 and a retryAfterMs field.
  • allow / shadow-ban: passes the request through to the application.
  • On detection failure, the middleware fails open and lets the request through.

The middleware also works with plain Starlette applications.

API Reference

Vix11Client(base_url, agent_id, api_key=None, timeout=5.0)

Creates a synchronous client instance.

AsyncVix11Client(base_url, agent_id, api_key=None, timeout=5.0)

Creates an asynchronous client instance.

detect(endpoint, payload, **params) -> DetectResponse

Run the 11-layer detection pipeline against a request.

Parameter Type Required Description
endpoint str Yes Target endpoint path
payload str Yes Request body as a string
**params Any No Additional fields (e.g., ip)

Returns a DetectResponse with an action field (allow, block, throttle, shadow-ban).

shield(endpoint, payload, **params) -> ShieldResponse

Run the shielded-request flow combining passport verification with the detection pipeline.

Parameters and return type follow the same pattern as detect.

get_detection_stats() -> dict

Retrieve detection pipeline statistics, including per-layer performance.

get_analytics_summary(from_ts=None, to_ts=None) -> dict

Retrieve the analytics summary for a time range, including the "$X saved" metric.

Parameter Type Required Description
from_ts int/None No Start timestamp (epoch)
to_ts int/None No End timestamp (epoch)

get_analytics_events(page=1, limit=50) -> dict

Retrieve paginated detection events.

Parameter Type Required Description
page int No Page number
limit int No Events per page

get_compliance_report() -> dict

Retrieve the current OWASP ASI compliance report.

health() -> dict

Check API health. Returns {"status": "ok"} when operational.

close() / await close()

Close the underlying httpx client and release resources.

Error Handling

All API errors are raised as Vix11Error exceptions.

from vix11.types import Vix11Error

try:
    result = client.detect(endpoint="/api/chat", payload="...")
except Vix11Error as e:
    print(f"HTTP status: {e.status}")
    print(f"Error message: {e.message}")

Vix11Error attributes:

Attribute Type Description
status int HTTP status code
message str Human-readable error message

Context Manager Usage

Both clients support context managers to ensure proper resource cleanup.

Synchronous:

from vix11 import Vix11Client

with Vix11Client(
    base_url="https://vix11.example.com",
    agent_id="my-agent",
) as client:
    result = client.detect(endpoint="/api/chat", payload="...")
    print(result.action)
# client is automatically closed here

Asynchronous:

from vix11 import AsyncVix11Client

async with AsyncVix11Client(
    base_url="https://vix11.example.com",
    agent_id="my-agent",
) as client:
    result = await client.detect(endpoint="/api/chat", payload="...")
    print(result.action)
# client is automatically closed here

Configuration

Option Type Required Default Description
base_url str Yes -- Base URL of the Vix11 API
agent_id str Yes -- Agent identifier sent with requests
api_key str / None No None API key for authenticated requests
timeout float No 5.0 Request timeout in seconds

License

MIT

Project details


Download files

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

Source Distribution

vix11-1.0.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

vix11-1.0.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file vix11-1.0.1.tar.gz.

File metadata

  • Download URL: vix11-1.0.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for vix11-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4acf5b1001ea089d03b8c1b88e8f19f757b7313d1140d0b1df3547f831e3e0ee
MD5 a438e6936632e19482deaf7ddc008f5e
BLAKE2b-256 0f647682c7caf67615747b01c60cdb4cf0c8dab5ba7683ab967149dc7ff3ec3c

See more details on using hashes here.

File details

Details for the file vix11-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: vix11-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for vix11-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a7b48532793ee0fe664089d96a8e22d7cc8cf9fdb6be029f3962f6300e194c4
MD5 2fc7f4de6c9ebb359f7d8a57376c22a3
BLAKE2b-256 e44ea63168d46d360833b91045e114db2d62190b379885ef3d0219ed2111d289

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 Pingdom Monitoring Sentry Error logging StatusPage Status page