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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d4f19b169457a2494e029728117142a7d13da06f03bccf791298b0bacccb8c8
|
|
| MD5 |
a42c9a88eedf92a9d3ea71d1b7e8036f
|
|
| BLAKE2b-256 |
6b7403c49c58e9cb78a6258137505d269179efbe72bfa9822f3ae4b24d12e854
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pulse_trace_sdk-0.2.4.tar.gz -
Subject digest:
9d4f19b169457a2494e029728117142a7d13da06f03bccf791298b0bacccb8c8 - Sigstore transparency entry: 975680741
- Sigstore integration time:
-
Permalink:
EK-LABS-LLC/trace-sdk-py@7ff270cfefce4bb4834ac74a49b1c9af04539874 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/EK-LABS-LLC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ff270cfefce4bb4834ac74a49b1c9af04539874 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pulse_trace_sdk-0.2.4-py3-none-any.whl.
File metadata
- Download URL: pulse_trace_sdk-0.2.4-py3-none-any.whl
- Upload date:
- Size: 2.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4915b0eeda345c5ff4c59d031cecddf8e6cf50e4a23a34c67eebdd060c515af
|
|
| MD5 |
659297b6d9d71684b2ee5ffd9bc0f337
|
|
| BLAKE2b-256 |
08ebd97e07e02505d2ded6bfc4e74573caf964b3bf5e76d1839258fa781d7b27
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pulse_trace_sdk-0.2.4-py3-none-any.whl -
Subject digest:
e4915b0eeda345c5ff4c59d031cecddf8e6cf50e4a23a34c67eebdd060c515af - Sigstore transparency entry: 975680744
- Sigstore integration time:
-
Permalink:
EK-LABS-LLC/trace-sdk-py@7ff270cfefce4bb4834ac74a49b1c9af04539874 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/EK-LABS-LLC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ff270cfefce4bb4834ac74a49b1c9af04539874 -
Trigger Event:
push
-
Statement type: