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.0.tar.gz (14.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.3.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contexere_ai-0.3.0.tar.gz
  • Upload date:
  • Size: 14.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.3.0.tar.gz
Algorithm Hash digest
SHA256 a276d1329a95a63cacda9a921cbb8bbe3d2a891947dbb5cf5216b2b911eed441
MD5 0191956fe17f27586dc8a61f7e02f6f3
BLAKE2b-256 2e3470fb1089c204b25c20851c6d34db1f3ee1753c2e8d3f5a25857ce82e09be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: contexere_ai-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bc4f8b3c0252046e6c9b6e85ac6b2a38bdda8c605f1804d96292bea29f301d8
MD5 d12fd9a8867cd48e1e458953e0110c6d
BLAKE2b-256 f49a4dd2aca82e83f6c87fff0606d36e52139d707cff6f59d7d9d6a04de944f3

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