Skip to main content

Pulse Python SDK for tracing LLM providers

Project description

Pulse Python SDK

Python client helpers for Pulse trace ingestion. Wrap your LLM provider SDK (OpenAI, Anthropic) and Pulse automatically captures trace metadata and ships it to your trace-service instance.

Installation

Install from PyPI:

pip install pulse-trace-sdk

For local development:

pip install -e .

Usage

from openai import OpenAI
from pulse_sdk import init_pulse, observe, Provider

init_pulse({
    "api_key": "pulse_sk_...",
    "api_url": "http://localhost:3000",
})

client = OpenAI(api_key="your-openai-key")
observed = observe(client, Provider.OPENAI)

response = observed.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello Pulse"}],
    pulse_session_id="session-123",
    pulse_metadata={"feature": "chat"},
)

To instrument Anthropic:

from anthropic import Anthropic
from pulse_sdk import observe, Provider

anthropic_client = Anthropic(api_key="anthropic-key")
observe(anthropic_client, Provider.ANTHROPIC)

anthropic_client.messages.create(
    model="claude-3-5-haiku-20241022",
    max_tokens=300,
    messages=[{"role": "user", "content": "Summarize"}],
)

API

  • init_pulse(config) – configure API URL, key, batch size, and flush interval. Starts a background worker that periodically flushes traces.
  • observe(client, provider, options=None) – wraps the provider SDK and returns the same client instance instrumented with tracing.
  • flush_buffer() – (optional) force-send buffered traces, useful before process shutdown.
  • shutdown() – stop the background worker and clear buffers.

Config options

init_pulse({
    "api_key": "pulse_sk_...",     # required
    "api_url": "https://api.example.com",  # default http://localhost:3000
    "batch_size": 10,               # flush when buffer hits this size
    "flush_interval": 5000,         # milliseconds between automatic flushes
    "enabled": True,                # set False to disable tracing
})

Pulse specific metadata

All chat.completions.create / messages.create calls support:

  • pulse_session_id – associate traces with a session.
  • pulse_metadata – arbitrary dictionary merged into trace metadata.

Requirements

  • Python 3.10+
  • requests
  • Corresponding provider SDK (openai, anthropic) for the helpers you use.

Tests

uv run pytest

Live integration check

To manually exercise the SDK against real providers, run:

uv run python tests/test_server.py openai
uv run python tests/test_server.py anthropic

Set PULSE_API_KEY and the relevant provider key (OPENAI_API_KEY or ANTHROPIC_API_KEY) before running. The script makes a single completion request and relies on observe() to push traces to your trace-service instance.

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

pulse_trace_sdk-0.2.4.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

pulse_trace_sdk-0.2.4-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

Details for the file pulse_trace_sdk-0.2.4.tar.gz.

File metadata

  • Download URL: pulse_trace_sdk-0.2.4.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pulse_trace_sdk-0.2.4.tar.gz
Algorithm Hash digest
SHA256 9d4f19b169457a2494e029728117142a7d13da06f03bccf791298b0bacccb8c8
MD5 a42c9a88eedf92a9d3ea71d1b7e8036f
BLAKE2b-256 6b7403c49c58e9cb78a6258137505d269179efbe72bfa9822f3ae4b24d12e854

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulse_trace_sdk-0.2.4.tar.gz:

Publisher: release.yml on EK-LABS-LLC/trace-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pulse_trace_sdk-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pulse_trace_sdk-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e4915b0eeda345c5ff4c59d031cecddf8e6cf50e4a23a34c67eebdd060c515af
MD5 659297b6d9d71684b2ee5ffd9bc0f337
BLAKE2b-256 08ebd97e07e02505d2ded6bfc4e74573caf964b3bf5e76d1839258fa781d7b27

See more details on using hashes here.

Provenance

The following attestation bundles were made for pulse_trace_sdk-0.2.4-py3-none-any.whl:

Publisher: release.yml on EK-LABS-LLC/trace-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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