Skip to main content

SwapGate

The open-source model-swap eval gate: production traces become evals, and a candidate model must pass before you swap. Move from rented frontier APIs to self-hosted open-weight models (Sarvam, Llama, Qwen) without silent regressions.

traces → capture → build-evals → compare → swap receipt (pass/fail)
  • Capture real traffic: LiteLLM callbacks, OpenTelemetry GenAI spans, sec-MCP logs.
  • Redact before storage: deterministic pseudonymisation, DPDP-aware profiles.
  • Build evals by clustering traces; a human approves rubrics before they run.
  • Compare baseline vs candidate with deterministic, LLM, or typed-decision judges.
  • Ship the receipt: signed JSON verdict + Markdown/HTML report; the GitHub Action fails the PR on regression.

Zero-dependency Python core (stdlib only). Apache-2.0.

Install

pip install swapgate
# or from source:
git clone https://github.com/nitishagar/swapgate.git
cd swapgate
uv venv && uv pip install -e '.[dev]'

60-second demo (fully offline)

swapgate capture --from litellm --in fixtures/traces-litellm.jsonl --out /tmp/events.jsonl
swapgate build-evals --in /tmp/events.jsonl --out /tmp/suite.json --name demo
swapgate build-evals --in /tmp/events.jsonl --out /tmp/suite.json --approve
swapgate compare --suite /tmp/suite.json --baseline mock:parity --candidate mock:regress \
  --fail-under 0.5 --out /tmp/receipt.json --report /tmp/report.md
# exit 2: candidate regressed. Inspect /tmp/report.md, then:
swapgate verify --receipt /tmp/receipt.json --key /tmp/demo.key  # if signed with --key

CLI

Command Purpose
capture --from litellm|otel|secmcp --in --out [--redact profile] Ingest raw traces
build-evals --in --out [--name] [--clusters] [--india-pack] [--approve] Cluster → suite (approval-gated)
compare --suite --baseline --candidate [--judge] [--fail-under] [--max-regression] [--out] [--report] [--key/--sign] Replay + gate (exit 2 on regression)
report --receipt --format md|html [--out] Render a receipt
verify --receipt --key Verify a signed receipt
serve-mcp stdio MCP server (compare_models, list_evals)

Providers: mock:parity|regress|seed-N (offline), openai-compat:<base-url>|<model> (live, key from SWAPGATE_API_KEY). Exit codes: 0 pass, 2 gate fail, 1 error.

GitHub Action

- uses: nitishagar/swapgate@v0
  with:
    suite: evals/suite.json
    baseline: openai-compat:https://api.example.com/v1|baseline-model
    candidate: openai-compat:https://api.example.com/v1|candidate-model
    fail-under: '0.95'
    max-regression: '0.02'

Gates (automated tests)

Every gate runs offline in CI (pytest, no keys/network):

  • G0 unit — ingest ×3, redact, cluster, evals, judges ×3, compare, receipt, report, India pack
  • G1 CLI end-to-end — capture→build-evals→compare on fixtures, golden receipt
  • G2 regression behaviour — injected regression fails (exit 2), parity passes (exit 0)
  • G3 judge reliability — deterministic fixtures + recorded LLM-judge fixtures
  • G4 receipt integrity — genuine verifies, tampered/unsigned/wrong-key rejected
  • G5 site + packaging — docs links, sdist install, Action metadata, TS SDK tests
  • L live (opt-in) — SWAPGATE_LIVE=1 pytest -m live vs a real endpoint
pytest            # G0–G5 offline

India pack (--india-pack)

Hinglish eval templates, DPDP redaction profiles (india, dpdp-strict: PAN, Aadhaar, UPI, +91 phones), 30-day retention guidance, and a FREE-AI control annex for fintech audit packets. See docs/india-pack.html.

Layout

src/swapgate/ core · tests/ gates · fixtures/ sample traces · action/ GitHub Action · packages/swapgate-js/ thin TS SDK · docs/ GitHub Pages site · examples/sarvam-swap/ mock swap demo.

Limits

  • Heuristic rubrics need human review (the approval gate enforces this); LLM rubric synthesis is live-only and not in v0.1.
  • Mock providers prove gate mechanics, not model quality.
  • HMAC receipts are tamper-evident, not third-party-verifiable (Ed25519 is the documented upgrade path).

License

Apache-2.0. See LICENSE.

Metadata

Release files for swapgate 0.2.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 swapgate 0.2.1
File Size Uploaded Provenance Actions
swapgate-0.2.1.tar.gz 130.5 kB With provenance Details for swapgate-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 180.3 kB

Release files / swapgate-0.2.1.tar.gz

Download URL swapgate-0.2.1.tar.gz
Size 130.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8fe0bb59acc663723d7f93c39e1a211a442342c9de2243e5083c633e0b901516
BLAKE2b-256 checksum
How to use checksums
8e77941cc01a7c5a6b25c7762f8f0de4e0b7d1221f491b9226087cdc850303f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 28, 2026.

Transparency log

Release files / swapgate-0.2.1-py3-none-any.whl

Download URL swapgate-0.2.1-py3-none-any.whl
Size 49.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85dd578178ef7682a9793e66941b575e713568943ec0e3fe199026133dd8602d
BLAKE2b-256 checksum
How to use checksums
caeeb14fb26f619a9c2167f476f5f6adbd4224f52ab9335ebc8af79a417f0226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 28, 2026.

Transparency log

Security for swapgate 0.2.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for swapgate-0.2.1.tar.gz

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 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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