Skip to main content

MemFlow Relay

Research Preview — MemFlow Relay is currently in research preview. APIs and behaviours may change without prior notice.

MemFlow Relay is a local HTTP proxy for Gemini API requests, developed by LamoonAGI. It transparently intercepts your Gemini calls and — depending on the configured operating mode — can analyse, optimise, or shadow-test context window usage before forwarding the request to Google Gemini.


Features

  • Shadow mode — observe without modification; original request is always forwarded unchanged.
  • Safe mode — apply optimizations only when confidence is high; fall back to original on any doubt.
  • Optimize mode — apply MemFlow context optimizations and track token savings.
  • Fail-open default — if the MemFlow optimizer is unreachable or times out, the relay always forwards the original request to Gemini.
  • Credential isolation — GEMINI_API_KEY never leaves your machine; it is never sent to LamoonAGI or MemFlow cloud services.
  • Secret redaction — all logs, exceptions, and telemetry automatically strip API keys, Bearer tokens, and cookies.
  • Telemetry modes — off, metrics_only (default, no prompt content), or diagnostic.

Installation

pip install memflow-relay

Requires Python ≥ 3.11.


Quick Start

# Set credentials
export MEMFLOW_API_KEY="lago_your_key_here"
export GEMINI_API_KEY="your_gemini_key_here"

# Start relay in shadow mode (safe default)
memflow-relay serve

# Verify setup
memflow-relay doctor

# Show live stats
memflow-relay stats

Your Gemini SDK base URL should be set to http://127.0.0.1:8765.


CLI Commands

Command Description
memflow-relay serve Start the local proxy (default port 8765)
memflow-relay doctor Verify credentials, connectivity, and port availability
memflow-relay test Run end-to-end shadow mode verification
memflow-relay stats Display analyzed / optimized / bypassed counts and token savings
memflow-relay benchmark Run baseline vs optimized Gemini workload comparison
memflow-relay version Report package version and research preview status

Configuration

All configuration is via environment variables. See .env.example for a full reference.

Variable Default Description
MEMFLOW_API_KEY — LamoonAGI API key (required for optimize/safe modes)
GEMINI_API_KEY — Google Gemini API key (never sent to LamoonAGI)
MEMFLOW_API_URL https://api.lamoonagi.com MemFlow optimizer endpoint
MEMFLOW_MODE shadow Operating mode: shadow, safe, optimize
MEMFLOW_TELEMETRY metrics_only Telemetry level: off, metrics_only, diagnostic
MEMFLOW_PORT 8765 Local proxy port
MEMFLOW_FAIL_OPEN true Forward original request if optimizer fails

Security

See SECURITY.md for vulnerability disclosure policy.

Key guarantee: GEMINI_API_KEY is used exclusively to authenticate requests to generativelanguage.googleapis.com. It is never included in requests to api.lamoonagi.com or any other endpoint.


License

MIT — see LICENSE.

© 2024 LamoonAGI. MemFlow is a product of LamoonAGI. Powered by LamoonAGI Context VMM technology.

Metadata

Release files for memflow-relay 0.1.1

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

Source distribution (sdist)

Source distribution for memflow-relay 0.1.1
File Size Uploaded
memflow_relay-0.1.1.tar.gz 26.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for memflow-relay 0.1.1
File Interpreter ABI Platform
memflow_relay-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 50.5 kB

Release files / memflow_relay-0.1.1.tar.gz

Download URL memflow_relay-0.1.1.tar.gz
Size 26.3 kB
Tags Source
SHA-256 checksum
How to use checksums
aacdb94b673ea38e845de921863d93890a43a7eaa6a8c6a58ba093d6c9734478
BLAKE2b-256 checksum
How to use checksums
61defd3ecaf913f34717deaa207256974f52b8a76037884b6d3920fe63bf6cb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / memflow_relay-0.1.1-py3-none-any.whl

Download URL memflow_relay-0.1.1-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b315c03488971c2d5be7518ab035f869c5213046fb064cf440c2b82f50718bfd
BLAKE2b-256 checksum
How to use checksums
f73be857490efc65283954b17f7a56f658809b39b5183fc270344184189230ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

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