Skip to main content

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 key
  • project_name: Logical project name for grouping traces
  • endpoint: 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

contexere_ai-0.3.1.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

contexere_ai-0.3.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file contexere_ai-0.3.1.tar.gz.

File metadata

  • Download URL: contexere_ai-0.3.1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for contexere_ai-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9e5cb6d79476fc3a70e0f3040b0d1c2ec739c54dc06f47a72f8009b92a246532
MD5 9087d7ac5672a45f3fdbedf3b807ae8f
BLAKE2b-256 75a7c1fdde8fdb510bdf04a9c59ea74b5c1688ec87691942753c0b085f446d0d

See more details on using hashes here.

File details

Details for the file contexere_ai-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: contexere_ai-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for contexere_ai-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e09c3cddd97b5a29cb634feaae80114bed588daf62ec1426c47ad58d11491c9
MD5 b3b964562b92e7ae55a78179c37dfd4b
BLAKE2b-256 f241a3cfe1c1a2cac1fda98c59d62b78a582002e5f50ef256941794684185b48

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