Skip to main content

Megflow AI API observability SDK — auto-instrument OpenAI, Anthropic and Gemini 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"}],
)

Auto-instrument Gemini

import google.generativeai as genai
from megflow_observability import MegflowObserve, wrap_gemini

genai.configure(api_key="YOUR_GOOGLE_API_KEY")
observe = MegflowObserve(api_key="obs_your_key_here")

model = wrap_gemini(genai.GenerativeModel("gemini-2.0-flash"), observe)
response = model.generate_content("Hello")

Optional dependencies

pip install megflow-observability[openai]      # includes openai
pip install megflow-observability[anthropic]   # includes anthropic
pip install megflow-observability[gemini]      # includes google-generativeai
pip install megflow-observability[all]         # includes all three

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.2.0.tar.gz (6.3 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.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: megflow_observability-0.2.0.tar.gz
  • Upload date:
  • Size: 6.3 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.2.0.tar.gz
Algorithm Hash digest
SHA256 55c9f1fd4d4cbaafb5b921bb5b0aa4b0e16268d2304d36ab05ce7b182d1ed594
MD5 89d36e2e107e15d29f0f307fb52a0b39
BLAKE2b-256 d53f142ddfd7cabfa655ec7f8647de68364c09df5c57958af58f66bca25fdd7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for megflow_observability-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c50f361fd77c39f6b75109cb20a88bbac3c1d4858b273b7784779f9743731a6
MD5 82e5802cf435a96de8fbbce979a51b1f
BLAKE2b-256 09a05533231a2b3b9a105df884f38215ceadecb7c06a31aaf53d3e161a51bf86

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