Metadata-Version: 2.4
Name: mizara
Version: 0.2.0
Summary: Mizara — programmable authorization layer for AI actions
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/getmizara/mizara-python
Keywords: ai-agents,authorization,policy-engine,access-control,llm,agent-security
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# Mizara SDK — Python

[![PyPI](https://img.shields.io/pypi/v/mizara?color=3776ab)](https://pypi.org/project/mizara/)
[![Python](https://img.shields.io/pypi/pyversions/mizara)](https://pypi.org/project/mizara/)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE.md)

Authorization layer for AI agents. Call `authorize()` before any consequential action. Sub-2ms evaluation, policy-as-data, cryptographic receipt on every decision.

Also available for TypeScript/Node.js: [`@mizara/sdk`](https://github.com/getmizara/mizara-node)

## Install

```bash
pip install mizara
```

## Quickstart

**Local policy file**

```python
from mizara import create_mizara_client

mizara = create_mizara_client(policy_path="./policy.json")

result = mizara.authorize(
    actor={"id": "agent_support_v4", "type": "autonomous_agent"},
    action={"name": "execute_refund"},
    resource={"type": "monetary_transaction", "id": "tx_99210",
              "attributes": {"amount": 75, "currency": "USD"}},
)

if result.status == "DENY":
    raise Exception(result.enforcement.user_facing_error)
# result.status                   -> 'ALLOW' | 'DENY' | 'REDACT' | 'RE_ROUTE'
# result.cryptographic_receipt.id -> 'rcpt_8f3c...'
```

**Hosted API** — sign up at [mizara.ai/signup](https://mizara.ai/signup), skip the local file:

```python
import os
from mizara import create_mizara_client

mizara = create_mizara_client(
    api_key=os.environ["MIZARA_API_KEY"],
    client_id="acme_corp",
)

result = mizara.authorize(
    actor={"id": "agent_1", "type": "autonomous_agent"},
    action={"name": "execute_refund"},
    resource={"type": "monetary_transaction", "id": "tx_1",
              "attributes": {"amount": 75}},
)
```

## Policy format

Plain JSON. No Rego, no Cedar syntax.

```json
{
  "policy_id": "pol_refund_v1",
  "client_id": "acme_corp",
  "rules": [
    {
      "id": "rule_max_refund",
      "target_action": "execute_refund",
      "condition": "resource.attributes.amount <= 50.00",
      "effect": "ALLOW",
      "fallback_effect": "DENY",
      "remediation_message": "Refund exceeds the $50 unapproved threshold."
    }
  ]
}
```

Condition expressions support comparisons, boolean logic, arithmetic, and `.contains()`:

```text
resource.attributes.amount <= 50.00
context.jurisdiction == 'EU' && context.data_classification.contains('PII')
context.session_total + resource.attributes.amount <= 500
```

## Integrations

| Framework | Example |
| --- | --- |
| LangGraph | [`examples/langgraph/`](examples/langgraph/) |
| OpenAI Agents SDK | [`examples/openai-agents/`](examples/openai-agents/) |
| Hosted API | [`examples/hosted-api/`](examples/hosted-api/) |

## Design choices

**Fail closed.** No matching rule returns `DENY`, not `ALLOW`.

**Policy as data.** Rules live in a JSON file that non-engineers can edit without a deploy.

**No Cedar or Rego.** Conditions are plain boolean expressions. The engine compiles them safely without `eval()`.

**Receipt on every call.** Even `ALLOW` decisions are signed and stored. The audit trail is part of the product, not an afterthought.

## License

Apache-2.0
