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.2.0.tar.gz
(20.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ciphyrs-2.2.0-py3-none-any.whl
(22.3 kB
view details)
File details
Details for the file ciphyrs-2.2.0.tar.gz.
File metadata
- Download URL: ciphyrs-2.2.0.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d213a702ecbdbd9af5b5272f27f1bfe886b2f6e91d89b6ac4dcf9ad0f50a97af
|
|
| MD5 |
9f35d47ead08f7f63522423ce02daad1
|
|
| BLAKE2b-256 |
dfc5afba50ea78d2c486e20e987109a9fad576c4006aa4dc93bd3bceab8ff42c
|
File details
Details for the file ciphyrs-2.2.0-py3-none-any.whl.
File metadata
- Download URL: ciphyrs-2.2.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
876cc53ed48fe358a472ea72c5fe96476f2c6d06d21d33831a3c6d074e01997c
|
|
| MD5 |
749f932062fa0237bcb5557db2ca3fe5
|
|
| BLAKE2b-256 |
04311249b1b82b42f2b13a4fe736942ec01da224dcf310b4675e6064ad886f52
|