Skip to main content

Official Python SDK for the ShieldCortex API — AI memory security scanning

Project description

shieldcortex

PyPI Python License

Official Python SDK for the ShieldCortex API — AI memory security scanning.

ShieldCortex is a 6-layer defence pipeline that protects AI agent memory from prompt injection, credential leaks, encoding attacks, and more.

Installation

pip install shieldcortex

With framework integrations:

pip install shieldcortex[crewai]     # CrewAI memory guard
pip install shieldcortex[langchain]  # LangChain callback handler

Quick Start

from shieldcortex import ShieldCortex

client = ShieldCortex(api_key="sc_live_...")

# Scan user input before storing in memory
result = client.scan("user input here")

if not result.allowed:
    print(f"Blocked: {result.firewall.reason}")
    print(f"Threats: {result.firewall.threat_indicators}")
else:
    print(f"Safe (trust: {result.trust.score})")

Async Support

from shieldcortex import AsyncShieldCortex

async with AsyncShieldCortex(api_key="sc_live_...") as client:
    result = await client.scan("user input here")

Batch Scanning

from shieldcortex import BatchItem

result = client.scan_batch([
    BatchItem(content="memory entry 1"),
    BatchItem(content="memory entry 2"),
])
print(f"Scanned: {result.total_scanned}, Threats: {result.threats}")

Audit Logs

from shieldcortex import AuditQuery

# Query with filters
logs = client.get_audit_logs(AuditQuery(level="BLOCK", limit=10))

# Auto-paginate through all entries
for entry in client.iter_audit_logs():
    print(entry.id, entry.firewall_result)

# Export as CSV
csv = client.export_audit_logs(format="csv")

CrewAI Integration

Scan all memory writes before they reach your store:

from shieldcortex import ShieldCortex
from shieldcortex.integrations.crewai import ShieldCortexMemoryGuard, MemoryBlockedError

client = ShieldCortex(api_key="sc_live_...")
guard = ShieldCortexMemoryGuard(client, mode="strict")

try:
    guard.check("content to remember")
    # Safe — save to memory store
except MemoryBlockedError as e:
    print(f"Blocked: {e.result.firewall.reason}")

LangChain Integration

Scan LLM inputs and outputs automatically:

from shieldcortex import AsyncShieldCortex
from shieldcortex.integrations.langchain import ShieldCortexCallbackHandler

client = AsyncShieldCortex(api_key="sc_live_...")
handler = ShieldCortexCallbackHandler(client, raise_on_block=True)

# Pass to any LangChain component
llm = ChatOpenAI(callbacks=[handler])

Error Handling

from shieldcortex.errors import AuthError, RateLimitError, ValidationError

try:
    result = client.scan("content")
except AuthError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except ValidationError:
    print("Invalid request")

Full API Coverage

The SDK covers all ShieldCortex API endpoints:

Category Methods
Scanning scan(), scan_batch(), scan_skill()
Audit get_audit_logs(), get_audit_entry(), get_audit_stats(), get_audit_trends(), export_audit_logs(), iter_audit_logs()
Quarantine get_quarantine(), get_quarantine_item(), review_quarantine_item()
API Keys create_api_key(), list_api_keys(), revoke_api_key()
Teams get_team(), update_team(), get_team_members(), get_usage()
Invites create_invite(), list_invites(), delete_invite(), resend_invite()
Billing create_checkout_session(), create_portal_session()
Devices get_devices(), register_device(), update_device(), device_heartbeat()
Alerts get_alerts(), create_alert(), update_alert(), delete_alert()
Webhooks get_webhooks(), create_webhook(), update_webhook(), delete_webhook(), test_webhook(), get_webhook_deliveries()
Firewall Rules get_firewall_rules(), get_active_firewall_rules(), create_firewall_rule(), update_firewall_rule(), delete_firewall_rule()

Documentation

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

shieldcortex-0.1.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

shieldcortex-0.1.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shieldcortex-0.1.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for shieldcortex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 030e7917f55845676a2be91c8547cd9c56f1ecc4cc600a741a35831ea29dc9e8
MD5 d48ca5167d3d6d4834133eba71cb8ff9
BLAKE2b-256 b1780d8513f4d2917188d31792c3f943b72930b0e549056584b86a161cbb7151

See more details on using hashes here.

Provenance

The following attestation bundles were made for shieldcortex-0.1.0.tar.gz:

Publisher: publish.yml on Drakon-Systems-Ltd/shieldcortex-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 shieldcortex-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: shieldcortex-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for shieldcortex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3875443020b1f5d961061ce3d851ce274d9e3b22beadc0e19fc183df50a1e0cf
MD5 0a9050172309a68cf4ddc75fbc54320e
BLAKE2b-256 e8b22cd203d5c0758ebc9cb0df608100867f334dc3280d39d64f52555c61cea1

See more details on using hashes here.

Provenance

The following attestation bundles were made for shieldcortex-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Drakon-Systems-Ltd/shieldcortex-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