Skip to main content

Prysm AI Python SDK

PrysmAI is the control plane for production AI.

This SDK gives you two integration paths into the same Prysm control plane:

  • Proxy path for application traffic you route through Prysm
  • MCP path for agent runtimes that connect to Prysm as a governance and evidence surface

Both paths should produce the same operational outcome in Prysm:

  • request traces
  • security findings
  • policy decisions
  • governance sessions
  • reviewable evidence

PyPI version Python 3.9+ License: MIT

Your App          -> Prysm Proxy (/api/v1) -> Model Provider
Agent Runtime     -> Prysm MCP   (/api/mcp) -> Same control plane

Installation

pip install prysmai

# Optional integrations
pip install prysmai[langgraph]
pip install prysmai[crewai]
pip install prysmai[agent-framework]
pip install prysmai[all]

Requires Python 3.9+.

The Golden Paths

1. Proxy path

Use this when you are building an AI application directly and want Prysm in the request path.

from prysmai import PrysmClient

prysm = PrysmClient(
    prysm_key="sk-prysm-...",
    base_url="https://prysmai.io/api/v1",
)

client = prysm.llm()

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Explain quantum computing simply."}],
)

print(response.choices[0].message.content)

2. Wrap an existing OpenAI client

Use this when you already have an OpenAI client and want to add Prysm without rewriting the rest of your app.

from openai import OpenAI
from prysmai import monitor

client = OpenAI()
monitored = monitor(client, prysm_key="sk-prysm-...")

response = monitored.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Summarize the meeting notes."}],
)

3. MCP path

Use this when your runtime connects to MCP-compatible tools and you want Prysm to act as the control and evidence layer.

from prysmai import PrysmClient

prysm = PrysmClient(prysm_key="sk-prysm-...")
mcp = prysm.mcp()

config = mcp.connection_config()

print(config.server_url)
print(config.headers)

For MCP-compatible runtimes, hand them:

  • config.server_url
  • config.headers

Then use Prysm's MCP tools and resources to record model calls, tool activity, decisions, file changes, and governance evidence.

4. Unified session scope

Use PrysmClient.session(...) when you want one correlated run across proxy traffic and governance activity.

from prysmai import PrysmClient

prysm = PrysmClient(prysm_key="sk-prysm-...")

with prysm.session(
    user_id="user_123",
    metadata={"feature": "support"},
    governance_task="Resolve a customer support request safely.",
    agent_type="codex",
    auto_check_interval=1,
) as run:
    client = run.llm()
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": "Draft a short response."}],
    )

    run.record_decision(
        description="Send a short and safe reply",
        selected_action="respond",
        severity="low",
    )

    run.run_tool(
        "search_docs",
        lambda query: {"result_count": 2, "query": query},
        "refund policy",
        tool_input={"query": "refund policy"},
    )

print(run.identifiers.session_id)
print(run.identifiers.governance_session_id)

Choosing The Right Path

Use the proxy path when:

  • your app already talks directly to an LLM provider
  • you want request/response capture automatically
  • you want security scanning on proxied traffic with minimal code changes

Use the MCP path when:

  • your runtime is MCP-native
  • you are connecting Prysm to an external agent runtime
  • you want session, decision, tool, and file evidence even when the model call happens outside Prysm's HTTP proxy

Use a unified session when:

  • one run spans model calls, tools, file changes, and governance activity
  • you want one correlated session in the Prysm dashboard

Core SDK Surface

PrysmClient

The root client for the Prysm control plane.

from prysmai import PrysmClient

prysm = PrysmClient(prysm_key="sk-prysm-...")

proxy_client = prysm.llm()
mcp_client = prysm.mcp()
session = prysm.session(governance_task="Review a change", agent_type="codex")

prysm.openai() still works as a backward-compatible alias. The newer prysm.llm() name is more honest because Prysm can route to Claude, Gemini, vLLM, Ollama, or another configured provider behind the same OpenAI-compatible surface.

prysm_context

Attach user, session, and metadata to proxied requests.

from prysmai import PrysmClient, prysm_context

client = PrysmClient(prysm_key="sk-prysm-...").openai()

with prysm_context(
    user_id="user_42",
    session_id="sess_checkout",
    metadata={"tenant": "acme", "feature": "checkout"},
):
    client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": "Help me check out."}],
    )

PrysmSession

Use PrysmSession helpers when you need to record governance-side events explicitly:

  • record_llm_call(...)
  • record_tool_call(...)
  • record_decision(...)
  • record_file_change(...)
  • record_delegation(...)
  • run_tool(...)
  • scan_code(...)

What Appears In Prysm

With the SDK wired correctly, Prysm can show:

  • model traces
  • latency, tokens, and cost
  • threat and policy findings
  • session events such as tool calls, decisions, and file changes
  • governance reports and reviewable evidence

Framework Integrations

The SDK also includes integrations for:

  • LangGraph
  • CrewAI
  • Microsoft Agent Framework
  • LlamaIndex

You can initialize these from the shared PrysmClient so they use the same auth and base URL model.

LangGraph

from prysmai import PrysmClient

prysm = PrysmClient(prysm_key="sk-prysm-...")
monitor = prysm.langgraph_monitor(
    user_id="user_123",
    metadata={"framework": "langgraph"},
    governance=True,
)

monitor.start_governance(
    task="Run a support workflow",
    available_tools=["search_docs"],
)

for chunk in graph.stream(
    {"question": "Handle a duplicate charge request"},
    config={"callbacks": [monitor]},
):
    ...

report = monitor.end_governance()
monitor.close()

Agent Framework

from prysmai import PrysmClient

prysm = PrysmClient(prysm_key="sk-prysm-...")
monitor = prysm.agent_framework_monitor(
    user_id="user_123",
    metadata={"framework": "agent_framework"},
    governance=True,
)

agent = client.as_agent(
    name="SupportBot",
    middleware=monitor.middleware(),
)

CrewAI and LlamaIndex

The SDK also includes:

  • prysm.crewai_monitor(...) for CrewAI event-bus telemetry
  • prysm.llamaindex_handler(...) for LlamaIndex callback telemetry

See the framework examples and developer guide for setup and optional dependencies.

Notes

  • LangGraph, Agent Framework, CrewAI, and LlamaIndex paths have all been exercised against a live local Prysm server, not just mock tests.
  • Framework integrations primarily emit telemetry and governance evidence into the same control plane used by the proxy and MCP paths.
  • Example files:
    • examples/langgraph_monitor.py
    • examples/agent_framework_monitor.py

Configuration

The SDK resolves connection settings from:

  • explicit arguments
  • then environment variables

Environment variables:

  • PRYSM_API_KEY
  • PRYSM_BASE_URL

Default base URL:

https://prysmai.io/api/v1

Local Development

For local Prysm development:

from prysmai import PrysmClient

prysm = PrysmClient(
    prysm_key="sk-prysm-...",
    base_url="http://localhost:8000/v1",
)

The MCP server for that same deployment will resolve to:

http://localhost:8000/mcp

More Documentation

Status

The SDK is still early, but the core product direction is now:

  • one control plane
  • two integration paths
  • shared evidence and governance outcomes

Metadata

Release files for prysmai 0.9.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 prysmai 0.9.0
File Size Uploaded Provenance Actions
prysmai-0.9.0.tar.gz 87.6 kB Without provenance Details for prysmai-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prysmai 0.9.0
File Interpreter ABI Platform Actions
prysmai-0.9.0-py3-none-any.whl Python 3 none any Details for prysmai-0.9.0-py3-none-any.whl

Total release size: 146.6 kB

Release files / prysmai-0.9.0.tar.gz

Download URL prysmai-0.9.0.tar.gz
Size 87.6 kB
Tags Source
SHA-256 checksum
How to use checksums
33478bfae71478e138a9803444921d5e03157b58d21496a860a54de1b3821d9a
BLAKE2b-256 checksum
How to use checksums
9a3da8c785a102aadb49557a0421a10fefb234a7bdb11fd3a14737ffbb04a399
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / prysmai-0.9.0-py3-none-any.whl

Download URL prysmai-0.9.0-py3-none-any.whl
Size 59.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a42059c2cbec5bfe187fa6f7b95a1785699458293247aaa7847efdcc919ed600
BLAKE2b-256 checksum
How to use checksums
99f10be3711bce06d57c6760e34180c2500510dba2ab16d820ba67d3e022727a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for prysmai 0.9.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.

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