Skip to main content

Python SDK for Sector8 AI telemetry, alerts, and MCP guard installation

Project description

Sector8 SDK

PyPI version Python 3.8+ License: MIT

Python SDK for sending AI telemetry and security events to Sector8.

Sector8 is an execution-boundary security platform for AI systems. The production Guard Module is live at https://sdkapi.sector8.ai.

What this package is for

Use sector8-sdk when you want to:

  • send telemetry for LLM calls to Sector8
  • emit threat alerts and incident logs from your application
  • install the Sector8 MCP guard helper into a local project

This package is intentionally simple. The paid wedge is the live guard and decision service, not a large client-side framework.

Installation

pip install sector8-sdk

Optional extras:

pip install sector8-sdk[openai]
pip install sector8-sdk[anthropic]
pip install sector8-sdk[google]
pip install sector8-sdk[all]

Quick start

Set your credentials:

export SECTOR8_API_KEY="your-api-key"
export SECTOR8_CLIENT_ID="your-client-id"

Send telemetry:

import sector8

client = sector8.setup(
    api_key="your-api-key",
    client_id="your-client-id",
)

client.log_llm_call(
    provider="openai",
    model="gpt-4o",
    tokens=150,
    cost=0.003,
    latency_ms=800,
    prompt="Summarize this contract.",
    completion="Here is the summary...",
)

Protect an action before execution:

decision = await client.evaluate(
    "bash",
    {"command": "git status"},
    caller_id="developer-1",
    role="developer",
    session_id="customer-onboarding-1",
)

if decision.allowed:
    run_the_action()
else:
    audit_log(decision.reason_code, decision.decision_trace_id)

A policy DENY is returned as a normal decision artifact. Authentication, scope, validation, transport, and malformed-response failures raise SDK errors. Never execute an action unless decision.allowed is True.

You can also call the async methods directly:

import asyncio
import sector8


async def main() -> None:
    client = sector8.setup(api_key="your-api-key", client_id="your-client-id")
    await client.save_telemetry(
        provider="openai",
        model="gpt-4o",
        prompt="Classify this email",
        completion="Likely phishing",
        tokens_used=240,
        latency_ms=620,
        cost=0.0048,
        success=True,
        metadata={"route": "inbound-mail"},
    )
    await client.close()


asyncio.run(main())

Threat alerts and incidents

import sector8

client = sector8.setup(api_key="your-api-key", client_id="your-client-id")
client.alert_threat("prompt_injection", severity="High", description="Jailbreak attempt detected")
client.log_incident("Sensitive file request denied", severity="high", classification="policy_deny")

MCP guard helper

This package also ships a small CLI for installing the Sector8 guard MCP entry into a project:

sector8-guard install
sector8-guard version

The installer writes .claude/settings.json entries that point at the repo-local MCP stdio server and pass through:

  • SECTOR8_API_KEY
  • SECTOR8_CLIENT_ID

Runtime endpoints used by this SDK

  • Production API: https://sdkapi.sector8.ai
  • Telemetry ingest: POST /api/v1/telemetry
  • Threat alerts: POST /api/v1/threat-alerts
  • Incident logs: POST /api/v1/incident-logs

Secure host configuration

The SDK uses https://sdkapi.sector8.ai by default and treats endpoint as the preferred configuration field. The legacy base_url alias is still accepted for compatibility.

  • plain HTTP is rejected by default
  • arbitrary remote hosts other than sdkapi.sector8.ai are rejected by default
  • endpoint values with /api/... paths, query strings, or fragments are rejected by default
  • local or mock testing requires explicit opt-in
client = sector8.setup(
    api_key="your-api-key",
    endpoint="http://localhost:9876",
    unsafe_endpoint=True,
)

Use unsafe_endpoint=True only for deliberate local or test use. The older allow_unsafe_base_url=True option remains available as a compatibility alias.

Links

  • Homepage: https://sector8.ai
  • Production API: https://sdkapi.sector8.ai
  • Dashboard: https://app.sector8.ai
  • Repository: https://github.com/sector8-ai/sector8-sdk-python

Development notes

This package targets Python 3.8+ and is published as sector8-sdk on PyPI.

Verify a new customer connection

$env:SECTOR8_API_KEY = "<one-time-reveal-runtime-key>"
$env:SECTOR8_CLIENT_ID = "<client-id>"
$env:SECTOR8_ENDPOINT = "https://stgsdkapi.sector8.ai" # omit for production
$env:SECTOR8_UNSAFE_ENDPOINT = "true" # required for deliberate staging use
sector8-verify

The verifier submits safe simulated actions only. It confirms one ALLOW, one DENY, and the canonical decision artifact fields without printing credentials or request payloads.

Never use production credentials with staging, local, or other unsafe endpoints. Never share a one-time reveal key. A successful run prints one ALLOW trace, one DENY trace, and Staging onboarding smoke passed.

Exit Meaning
0 Verification passed
2 Missing or invalid configuration
3 Endpoint/network unavailable
4 Malformed or unexpected decision contract
5 Authentication failed or key lacks scope

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

sector8_sdk-1.0.2.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

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

sector8_sdk-1.0.2-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file sector8_sdk-1.0.2.tar.gz.

File metadata

  • Download URL: sector8_sdk-1.0.2.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sector8_sdk-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c871a1400b4725767cd7322febbfad8b1cabc43366b6f61119ee8b2aff7ccbf4
MD5 d5285b3b1c913f27662a44a716624d99
BLAKE2b-256 6d6200b403760b1a394a1cae73286a8152294773c8eaeb7ecab53631a62621ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for sector8_sdk-1.0.2.tar.gz:

Publisher: release-pypi.yml on sector8-ai/sector8-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sector8_sdk-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: sector8_sdk-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sector8_sdk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f3cd7c2b6629901352fe4d6fcad1a607aeb768d38d96e626e8e413c3b4f06554
MD5 6cc2e98fa00de0da015e239f74770efa
BLAKE2b-256 afb611ed23d7104b96693914cb7cf780247acfb73230a5c976e7d05d9a016b9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sector8_sdk-1.0.2-py3-none-any.whl:

Publisher: release-pypi.yml on sector8-ai/sector8-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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