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.2.1.tar.gz (8.0 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.2.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contexere_ai-0.2.1.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

Hashes for contexere_ai-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4532a593fc45b398cd1e7aaf8ffc0357c1efa4a03a1cde35881bdaf9247cae04
MD5 a4fd364d7f04ff0f3a7b9c5df67f9539
BLAKE2b-256 01397e559331b65c03dd246b80c74d7f76ce74ae2fa053e93fa8e5adfba14d1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: contexere_ai-0.2.1-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

Hashes for contexere_ai-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b0251264bf013b7ccf80dc7c6e5ff4c07252182ff00472585672bd70ca29d3a
MD5 e03ab52d4ef8730f022a905df7a9e8d3
BLAKE2b-256 ad43ff2b46f798b589ea3e4080184335778d76368c18444789d185dbbda8516c

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