Skip to main content

Megflow AI API observability SDK — auto-instrument OpenAI and Anthropic calls

Project description

megflow-observability

Python SDK for Megflow AI Observability — track tokens, cost, latency and errors across OpenAI, Anthropic, Gemini and more.

Install

pip install megflow-observability

Quick start

from megflow_observability import MegflowObserve

observe = MegflowObserve(api_key="obs_your_key_here")

observe.track(
    provider="openai",
    model="gpt-4o",
    input_tokens=100,
    output_tokens=50,
    total_tokens=150,
    cost_usd=0.00075,
    latency_ms=320,
    status_code=200,
)

Auto-instrument OpenAI

from openai import OpenAI
from megflow_observability import MegflowObserve, wrap_openai

client = wrap_openai(OpenAI(), MegflowObserve(api_key="obs_your_key_here"))

# All calls are tracked automatically
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)

Auto-instrument Anthropic

import anthropic
from megflow_observability import MegflowObserve, wrap_anthropic

client = wrap_anthropic(anthropic.Anthropic(), MegflowObserve(api_key="obs_your_key_here"))

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)

Optional dependencies

pip install megflow-observability[openai]      # includes openai
pip install megflow-observability[anthropic]   # includes anthropic
pip install megflow-observability[all]         # includes both

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

megflow_observability-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

megflow_observability-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for megflow_observability-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ec8a775a7fe2186a2dceaf776309325e7eb702590fdb917005e7a5a0cb13783
MD5 5dfca0f64a36f45710fbf28ecc5a0daa
BLAKE2b-256 1b044ca40e34c7f356beb0833b7c0bfb0f5c283cc491cbf729ef2907fcd44b73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for megflow_observability-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b54e4cf401ed4a765b3faabfcad290407d0e24d303a24e00091e1090d29cbd3a
MD5 164fdce5f09af9c158a80022b2da936d
BLAKE2b-256 dcf38bb10b224ccb47d4cfc3d4a74d01885baa098f66699285e7c84f1e920df9

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