Metadata-Version: 2.4
Name: pfc-client
Version: 0.1.4
Summary: Lightweight Python SDK for the PFC API
Author: Dan Evans
License-Expression: MIT
Project-URL: Homepage, https://pfc-api.fly.dev
Project-URL: Source, https://github.com/danlevans1/PFC-runtime
Keywords: pfc,governance,ai,sdk,api
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28
Dynamic: license-file

# pfc-client

`pfc-client` is the lightweight Python SDK for customers integrating with the PFC API.

## Install

```bash
pip install pfc-client
```

For local development from this repository:

```bash
pip install ./sdk/python
```

## Quickstart

```python
from pfc_client import PFCClient, guarded_tool

client = PFCClient(
    api_url="https://pfc-api.fly.dev",
    api_key="YOUR_API_KEY",
)

decision = client.evaluate(
    action="deploy_production",
    subject={"type": "agent", "id": "website-backend"},
    resource={"type": "service", "id": "checkout-api"},
)

print(decision)
```

## Base URL Configuration

By default the client points to the hosted PFC API:

```python
client = PFCClient()
```

To use a different environment:

```python
client = PFCClient(api_url="https://your-pfc-host.example.com")
```

## API Key Usage

Pass your website customer API key when creating the client:

```python
client = PFCClient(
    api_url="https://pfc-api.fly.dev",
    api_key="pfc_live_your_api_key",
)
```

The SDK sends the key as the `x-api-key` header on evaluate requests.

## Check Your Usage

`API Key Usage` refers to how you authenticate requests.

`API Usage` refers to how you check your customer-specific request totals after authenticating.

To view your own usage, call the hosted usage endpoint with the same API key:

```bash
curl https://pfc-api.fly.dev/v1/usage/me \
  -H "x-api-key: YOUR_PFC_API_KEY"
```

The current Python SDK does not yet expose a `client.get_usage()` helper. The HTTP endpoint is available today, and adding an SDK method for usage lookup would be a good future enhancement.

## Guarded Tool Example

```python
from pfc_client import PFCClient, guarded_tool

client = PFCClient(api_key="pfc_live_your_api_key")


@guarded_tool(client)
def deploy():
    print("Deploying to production")


deploy()
```

## Supported Operations

- `client.evaluate(...)` submits an action for policy and authority evaluation
- `client.verify(...)` verifies an artifact against a public key via the API
