Skip to main content

Drop-in observability for AI agents — Python SDK

Project description

logspine · Python SDK

Drop-in observability for AI agents. Track every OpenAI and Anthropic call with cost, tokens, and latency — no code changes to your prompts.

Full docs: logspine.dev/docs


Install

pip install logspine

# with OpenAI support
pip install "logspine[openai]"

# with Anthropic support
pip install "logspine[anthropic]"

# both
pip install "logspine[openai,anthropic]"

Quick start — OpenAI

import openai
from logspine import LogspineClient

logspine = LogspineClient(api_key="lsk_live_...")
client = logspine.instrument_openai(openai.OpenAI())

# Every call is now tracked automatically
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(response.choices[0].message.content)

logspine.flush()  # call before process exit

Quick start — Anthropic

import anthropic
from logspine import LogspineClient

logspine = LogspineClient(api_key="lsk_live_...")
client = logspine.instrument_anthropic(anthropic.Anthropic())

response = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=256,
    messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(response.content[0].text)

logspine.flush()

Optional span metadata

Pass a logspine dict as an extra kwarg to tag individual calls:

client.chat.completions.create(
    model="gpt-4o",
    messages=[...],
    logspine={
        "trace_id": "my-session-abc123",
        "name": "summarise_document",
        "user_id": "usr_42",
    },
)

Links

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

logspine-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

logspine-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logspine-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for logspine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7d83ab564a6b54dff49b0ec1eb59a23c33f1ea87f9cfdf8fb71643707b909f6
MD5 20a8ec6ac834692595092b20a0f5d3ca
BLAKE2b-256 9f3563269efb7c73badfed1c01aeb32a5dac9974a38eda62a23fde9fa2f60760

See more details on using hashes here.

File details

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

File metadata

  • Download URL: logspine-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for logspine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 333695e1c81ca1f17d9510824b1dd2bc72aee8ec4e29bec02cf864839b7ac5bc
MD5 74e3e22917fe051d4ee8127407158f95
BLAKE2b-256 c55b21805e74d81fe25de820ed28032ca4a9a572391e51ab552a2437aee42336

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