Skip to main content

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

Or do both in one step:

metergraphrelay sync openai -n 25 --output 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
metergraphrelay sync openai -n 25 --output my-traces.jsonl --route my-app/support-bot

sync openai accepts the same flags as pull openai. It pulls to --output and immediately pushes that same file, checking both OPENAI_API_KEY and METERGRAPH_APP_TOKEN upfront so it fails fast instead of pulling data it can't push.

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.3"
}

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

Release files for metergraphrelay 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metergraphrelay 0.1.3
File Size Uploaded
metergraphrelay-0.1.3.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metergraphrelay 0.1.3
File Interpreter ABI Platform
metergraphrelay-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / metergraphrelay-0.1.3.tar.gz

Download URL metergraphrelay-0.1.3.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2f0df8b9afeb898fefd464b8b642c9ac6a4899898406e5ee7e89bc9fd30a5d7f
BLAKE2b-256 checksum
How to use checksums
d242938c1d8cc58e4021c687613a2de78a7aca3e1258f72b639ac66e84d521c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Release files / metergraphrelay-0.1.3-py3-none-any.whl

Download URL metergraphrelay-0.1.3-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11922fea4976d9aadf2364d52bc731d0bedf817b39842c555bf55576731e3f05
BLAKE2b-256 checksum
How to use checksums
9f34d5c105f08c869f0d54a99fdc50cd2bced71946dd785f3be41e94cc0dd6a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Release history Release notifications | RSS feed

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page