LLM Tracing and Context Engineering for Production AI Agents
Project description
Contexere
LLM Tracing and Context Engineering for Production AI Agents
Contexere is a lightweight Python library for tracing LLM applications and agent workflows in production.
Installation
pip install contexere
Quick Start
import contexere as conte
from openai import OpenAI
# Initialize Contexere
conte.init(
api_key="ck_...", # Your Contexere API key
project_name="my-agent"
)
# Instrument your OpenAI client
client = conte.instrument_openai(OpenAI(api_key="sk_..."))
# Trace function executions
@conte.op()
def process_query(question):
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": question}]
)
return response.choices[0].message.content
# All calls are now traced automatically
result = process_query("What is the capital of France?")
Features
- Function-level tracing: Use
@conte.op()to trace any function - LLM call tracing: Automatic instrumentation for OpenAI calls
- Captures everything: Inputs, outputs, exceptions, latency, token usage
- Project grouping: Organize traces by project name
- Non-blocking: Never breaks your code, even if tracing fails
API Reference
conte.init(api_key, project_name="default", endpoint=None, enabled=True)
Initialize the Contexere SDK.
api_key: Your Contexere API keyproject_name: Logical project name for grouping tracesendpoint: Custom backend endpoint (optional)enabled: Enable/disable tracing
@conte.op(name=None)
Decorator to trace function execution.
name: Optional custom name for the span (defaults to function name)
conte.instrument_openai(client)
Wrap an OpenAI client to trace all LLM calls.
client: An OpenAI client instance
Returns an instrumented client that traces all calls.
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
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
File details
Details for the file contexere_ai-0.2.0.tar.gz.
File metadata
- Download URL: contexere_ai-0.2.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4509d55145a07b86b4353b217bb3a6dc8a826fcd8ac27a09f449918718c8c1a
|
|
| MD5 |
d9e91e1e3a3af1ca91841e4d45adda59
|
|
| BLAKE2b-256 |
a3e2a0fee13b550cee4cc6136b68b4793629647812afe3f45b653a1933279051
|
File details
Details for the file contexere_ai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: contexere_ai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29a10809b461aaae3cfb25d6b1955e1cefb866d5b2808ae85a5a7d5c5c5ce4fb
|
|
| MD5 |
c557e3b683ef0e3cac8abf2476113d4e
|
|
| BLAKE2b-256 |
d78933a9d67e5989191c074f9178099de0145cbf540122e84a6d9a75ba7389d2
|