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.1.0.tar.gz (8.5 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.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contexere_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 8e31c8a8f6b812a7488490dfcbf57e68f9cf147544c262b63be6f0e870f11130
MD5 239504d4b77c506750e48217fa6c6004
BLAKE2b-256 e3317d461d477b75e1b51c87c9381ea10709fb587d96f11a02d99820d7a4092d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: contexere_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24f10b81a338e4cbdb58e2abc354d4d67dcda3cc830c0ae5116c5f40df26d624
MD5 52ef209c4cfa723e3f2e19318571b70a
BLAKE2b-256 cc1d49f7362007ab4e31bd0a0528008fe7a5290f3c6b8f683b851124aeebf394

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