Metadata-Version: 2.4
Name: cognisafe
Version: 0.1.0
Summary: LLM observability, cost tracking, and safety scoring
Author: Cognisafe LTD
Author-email: Cognisafe LTD <hello@cognisafe.uk>
License: MIT
Project-URL: Homepage, https://cognisafe.uk
Project-URL: Documentation, https://cognisafe.uk/docs
Project-URL: Repository, https://github.com/AiGentSmith/Cognisafe-platform
Keywords: llm,observability,openai,anthropic,safety,monitoring,ai
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Classifier: Intended Audience :: Developers
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == "openai"
Requires-Dist: httpx>=0.25.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.25; extra == "anthropic"
Provides-Extra: mistral
Requires-Dist: mistralai>=1.0; extra == "mistral"
Provides-Extra: cohere
Requires-Dist: cohere>=5.0; extra == "cohere"
Provides-Extra: all
Requires-Dist: openai>=1.0; extra == "all"
Requires-Dist: httpx>=0.25.0; extra == "all"
Requires-Dist: anthropic>=0.25; extra == "all"
Requires-Dist: mistralai>=1.0; extra == "all"
Requires-Dist: cohere>=5.0; extra == "all"
Dynamic: author
Dynamic: requires-python

# cognisafe

LLM observability, cost tracking, and automated safety scoring — by [Cognisafe](https://cognisafe.uk).

Instrument your LLM calls in two lines. Every request is captured, costed, and scanned for safety issues in the background — with zero latency impact.

## Installation

```bash
pip install cognisafe
```

Or with provider extras:

```bash
pip install "cognisafe[openai]"       # OpenAI + httpx
pip install "cognisafe[anthropic]"    # Anthropic
pip install "cognisafe[all]"          # All providers
```

## Quick start

### 1. Get your API key

Sign up at [cognisafe.uk](https://cognisafe.uk) and create an API key in **Settings**.

### 2. Instrument your code

**OpenAI (auto-patch)**

```python
import openai
import cognisafe

cognisafe.configure(
    api_key="csk_...",
    project_id="my-project",
    api_url="https://cognisafe.uk",
)
cognisafe.patch_openai()

client = openai.OpenAI(api_key="sk-...")
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)
```

**Manual tracing (any provider)**

```python
import cognisafe

cognisafe.configure(api_key="csk_...", api_url="https://cognisafe.uk")

messages = [{"role": "user", "content": "Hello"}]

with cognisafe.traced(model="gpt-4o", request_body={"messages": messages}) as ctx:
    response = client.chat.completions.create(model="gpt-4o", messages=messages)
    ctx["response_body"] = {
        "choices": [{"message": {"content": response.choices[0].message.content}}],
        "usage": {
            "prompt_tokens": response.usage.prompt_tokens,
            "completion_tokens": response.usage.completion_tokens,
        },
    }
```

**Anthropic**

```python
import anthropic
import cognisafe

cognisafe.configure(api_key="csk_...", api_url="https://cognisafe.uk")
cognisafe.patch_anthropic()

client = anthropic.Anthropic()
response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
```

## What you get

- **Requests dashboard** — every LLM call with model, tokens, cost, latency
- **Safety scoring** — automated threat detection on every prompt/response (content safety, PII detection, jailbreak detection)
- **Cost tracking** — per-project spend with tier limits
- **Governance** — red-team assessment runs against any LLM endpoint

## Supported providers

| Provider | Mode |
|---|---|
| OpenAI | Auto-patch |
| Azure OpenAI | Auto-patch |
| Anthropic | Auto-patch |
| Mistral | Auto-patch |
| Cohere | Auto-patch |
| Any provider | Manual (`traced`) |

## Links

- [Dashboard](https://cognisafe.uk)
- [Docs](https://cognisafe.uk/docs)
- [npm package](https://npmjs.com/package/cognisafe) (JavaScript/TypeScript)
