Skip to main content

Official Ciphyrs SDK for Python — agent tracing, observability, and PII detection

Project description

Ciphyrs Python SDK

Official Python SDK for Ciphyrs -- agent tracing, observability, and PII detection.

Installation

pip install ciphyrs

With integrations:

pip install ciphyrs[openai]      # OpenAI auto-tracing
pip install ciphyrs[langchain]   # LangChain callback handler

Quick Start

Basic Tracing

import ciphyrs

# Initialize the SDK
client = ciphyrs.init(api_key="ck_your_key", project="my-project")

# Trace a pipeline with spans
with client.trace("research_pipeline") as t:
    t.trigger_input = "What is quantum computing?"

    with client.span("Researcher", kind="llm_call", model_name="gpt-4") as s:
        s.set_input("What is quantum computing?")
        result = "Quantum computing uses qubits..."
        s.set_output(result)
        s.set_tokens(prompt_tokens=50, completion_tokens=200)

    with client.span("Summarizer", kind="llm_call") as s:
        s.set_input(result)
        summary = "QC leverages quantum mechanics for computation."
        s.set_output(summary)

    t.final_output = summary

Decorator-Based Tracing

import ciphyrs

ciphyrs.init(api_key="ck_your_key", project="my-project")

@ciphyrs.trace(name="research_task")
def run_pipeline(query):
    result = research(query)
    return summarize(result)

@ciphyrs.span(agent_name="Researcher", kind="llm_call")
def research(query):
    return llm.complete(query)

@ciphyrs.span(agent_name="Summarizer", kind="llm_call")
def summarize(text):
    return llm.complete(f"Summarize: {text}")

run_pipeline("What is AI?")

OpenAI Auto-Tracing

import ciphyrs
from ciphyrs.integrations.openai import patch_openai
from openai import OpenAI

ciphyrs.init(api_key="ck_your_key", project="my-project")
patch_openai()

openai_client = OpenAI()

# All OpenAI calls inside a trace are automatically captured
with ciphyrs.get_client().trace("chat_pipeline"):
    response = openai_client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Hello!"}]
    )

LangChain Integration

import ciphyrs
from ciphyrs.integrations.langchain import CiphyrsCallbackHandler

client = ciphyrs.init(api_key="ck_your_key", project="my-project")
handler = CiphyrsCallbackHandler(client=client, trace_name="langchain_run")

# Use with any LangChain chain
result = chain.invoke(
    {"input": "What is AI?"},
    config={"callbacks": [handler]}
)

handler.flush()  # Send the trace

Direct Ingestion

client = ciphyrs.CiphyrsClient(api_key="ck_your_key")

client.ingest(
    project={"name": "my-project", "framework": "custom"},
    trace={
        "trace_id": "abc-123",
        "name": "my-trace",
        "status": "completed",
    },
    spans=[
        {
            "span_id": "span-1",
            "agent_name": "MyAgent",
            "kind": "agent",
            "input": "hello",
            "output": "world",
            "duration_ms": 150,
            "status": "ok",
        }
    ],
)

Span Kinds

Kind Description
agent An autonomous agent step
llm_call A call to an LLM (OpenAI, Anthropic, etc.)
tool_call A tool/function invocation
retrieval A vector DB or search query

Configuration

client = ciphyrs.CiphyrsClient(
    api_key="ck_your_key",
    base_url="https://api.ciphyrs.com",  # or self-hosted URL
    project="my-project",
    framework="langchain",
    max_buffer_size=10,    # flush after 10 traces
    flush_interval=30.0,   # auto-flush every 30 seconds
)

License

MIT

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

ciphyrs-2.4.0.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

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

ciphyrs-2.4.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file ciphyrs-2.4.0.tar.gz.

File metadata

  • Download URL: ciphyrs-2.4.0.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ciphyrs-2.4.0.tar.gz
Algorithm Hash digest
SHA256 6e5e2ed50060f483ff19a1315bc60983ff94d719c16b2ef82ecdbf71188031fa
MD5 348edbe4cf8c3a5f0cfe8b09ab872afa
BLAKE2b-256 6c9216efff50dbd3ed88dc8079e4d138a143c1a819dc0ddf4292a3c24ad42f7b

See more details on using hashes here.

File details

Details for the file ciphyrs-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: ciphyrs-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ciphyrs-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e83b1a6c3d4c4649d14183b0d65cf7911aa2d6e7ab9ad19d2857bfb4d02e9a47
MD5 079ceaf68f10d70ae688c2cb3615756f
BLAKE2b-256 92bbf6e18cdb750c004502a5bc616c76ba2c0e50135b92234536aa159b21e229

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