Skip to main content

LLM observability, cost tracking, and safety scoring

Project description

cognisafe

LLM observability, cost tracking, and automated safety scoring — by Cognisafe.

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

pip install cognisafe

Or with provider extras:

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 and create an API key in Settings.

2. Instrument your code

OpenAI (auto-patch)

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)

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

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

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

cognisafe-0.1.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

cognisafe-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cognisafe-0.1.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cognisafe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9f17638916cbfde0acbbd24c862894e7055b572f52ce5756b4f2c9c19c5b37a3
MD5 5b9a09e689c514bc40616e8de2262065
BLAKE2b-256 40665508087e141012f7dc1bdf9c2bfdfa8e316b0689ea4d6102a058f260885f

See more details on using hashes here.

File details

Details for the file cognisafe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cognisafe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cognisafe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ebc396ecdc23a0dbd2160e53e543bebb7ac7d7ee0ebeb12dbfe2e9a18f66c70
MD5 3a983bb2c45be4ffa435652591571cea
BLAKE2b-256 1921a2316d135562d0614b05cb05465aaab89c1c17731facfd611bfb8b355a63

See more details on using hashes here.

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