Skip to main content

Move LLM trace data between systems: pull from providers, push to metergraph.

Project description

metergraphrelay

Try metergraph without installing its SDK: export the chat completions OpenAI already stores for you, and push them into metergraph.

  1. Your app calls OpenAI with store=True — a one-line addition if it doesn't already (see below). OpenAI keeps the completion server-side.
  2. metergraphrelay pull openai lists those stored completions via OpenAI's own API and writes them as JSONL, already shaped to metergraph's native trace schema.
  3. metergraphrelay push uploads that file to metergraph.

No SDK, no instrumentation beyond the store=True flag — which is also what OpenAI's own dashboard and evals features use.

This only reads what's associated with the API key you provide; it can't see or export anyone else's data. Built on OpenAI's List Chat Completions API — see the API reference for the underlying data model.

Setup

pip install metergraphrelay

Create a .env file in your working directory:

OPENAI_API_KEY=sk-...
METERGRAPH_APP_TOKEN=...

Quickstart

metergraphrelay pull openai -n 25 --output traces.jsonl
metergraphrelay push traces.jsonl

No stored completions yet? Generate a couple first:

metergraphrelay demo openai

Enabling storage on your own calls

pull openai only finds completions created with store=True. Add it to calls you're already making:

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "..."}],
    store=True,
    metadata={"source": "my-app"},  # optional, filterable later
)

Before enabling this in production:

  • Stored completions include full request/response content by default.
  • There's no automatic expiry from OpenAI's side — delete via their Delete chat completion API; metergraphrelay doesn't do this for you.

Commands

metergraphrelay pull openai -n 25 --output my-traces.jsonl --stdout --include-content --route my-app/support-bot
metergraphrelay demo openai --model gpt-4o-mini
metergraphrelay push traces.jsonl

pull anthropic / pull langfuse accept the same shape but aren't implemented yet — they check for ANTHROPIC_API_KEY / LANGFUSE_PUBLIC_KEY+LANGFUSE_SECRET_KEY and report accordingly.

All subcommands accept --env-file PATH.

Trace record shape

Each line of pull openai's output is a JSON object already shaped for metergraph's ingest API:

{
  "ts": "2026-07-30T12:00:00+00:00",
  "provider": "openai",
  "model": "gpt-4o-mini",
  "status": "success",
  "endpoint": "chat.completions",
  "input_tokens": 12,
  "output_tokens": 34,
  "error": false,
  "error_type": null,
  "request_id": "chatcmpl-...",
  "tags": {},
  "route": "openai/backfill",
  "content_opted_in": false,
  "request_json": null,
  "response_text": null,
  "sdk": "metergraphrelay",
  "sdk_version": "0.1.2"
}

request_json/response_text are populated only when --include-content is passed.

Every completion returned by the stored-completions list already succeeded, so status is always "success". error/error_type flag a partial record: --include-content was requested but the follow-up message fetch failed, so token counts are still real while the content is missing.

Development

git clone https://github.com/VasiliyRad/metergraphrelay
cd metergraphrelay
pip install -e ".[dev]"
pytest

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

metergraphrelay-0.1.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

metergraphrelay-0.1.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file metergraphrelay-0.1.2.tar.gz.

File metadata

  • Download URL: metergraphrelay-0.1.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.3

File hashes

Hashes for metergraphrelay-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f6c35feb66e072945f0382a9d1892a420c439c9a3771d6d9a07069061602e0ae
MD5 eec9f4e27062532f65854d23cd05e7d6
BLAKE2b-256 c65f11b0c2249c74e0ac4d9c35b6230439ea0ed64700ebd6b4e4e15b8f847e62

See more details on using hashes here.

File details

Details for the file metergraphrelay-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for metergraphrelay-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6dc5ea19ffeb3bde702099321e8aeacff94c78eb4b512c089cfdf0225e062be1
MD5 8e8c8a7be098fc5b789e6ea71805ddd5
BLAKE2b-256 5ee2c385a10540f40aab5e0591a3b88e21d2dc9429546d80ef5094a787ab08dc

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