prxy.monster API-key BYOK is live. Start free

Modules

A module is a small middleware that participates in one or more lifecycle hooks. Modules ship as npm packages that implement a tiny interface — six fields, four of them optional.

The interface

import type { Module } from '@prxy/module-sdk';
 
export const myModule: Module = {
  name: 'my-module',
  version: '1.0.0',
 
  async init(storage) {
    // optional: one-shot setup at server boot
  },
 
  async pre(ctx) {
    // optional: pre-request hook (mutate or short-circuit)
    return { continue: true };
  },
 
  async stream(chunk, ctx) {
    // optional: per-chunk hook for streaming responses
    return chunk;
  },
 
  async post(ctx) {
    // optional: post-response hook (side effects)
  },
};

Full SDK reference at /sdk/interface.

Module categories

Each built-in module fits one of seven categories. Knowing the category tells you roughly where it should sit in the pipeline:

CategoryPurposeWhere in pipelineExamples
cacheSkip the provider callFirstexact-cache, semantic-cache, tool-cache
safetyBlock bad requests earlyEarlycost-guard, guardrails, airgap
optimizationReduce tokens sentMidmcp-optimizer, prompt-optimizer
contextManage messages arrayMidipc, rehydrator, compaction-bridge
injectionAdd to promptLatepatterns
routingChoose model/providerLast pre hookrouter
trackingLog + bill + learnPost hooksusage-tracker

Built-in modules

Availability matrix

Status values are production, preview, planned, or deprecated.

ModuleStatusCloudLocalStreamingRequires storageRequires provider keyDocsLast updated
mcp-optimizerproductionyesyespre-hooksyesno/modules/mcp-optimizer2026-05-03
exact-cacheproductionyesyesyesyesno/modules/exact-cache2026-05-03
semantic-cacheproductionyesyesyesyesno/modules/semantic-cache2026-05-03
patternsproductionyesyespartial: injection works, streaming post-forge is skippedyesno/modules/patterns2026-05-03
cost-guardproductionyespartial: local has no hosted billing ledgeryesyesno/modules/cost-guard2026-05-03
ipcproductionyesyesyesyesno/modules/ipc2026-05-03
routerproductionyesyespre-hooksoptionalno/modules/router2026-05-03
rehydratorproductionyesyespre-hooksyesno/modules/rehydrator2026-05-03
compaction-bridgeproductionyesyespre-hooksyesno/modules/compaction-bridge2026-05-03
prompt-optimizerproductionyesyespre-hooksnono/modules/prompt-optimizer2026-05-03
tool-cachepreviewyesyespartial: observes/records, does not inject cached tool results yetyesno/modules/tool-cache2026-05-03
guardrailsproduction for regex backend; external backends plannedyesyespre-hooksnono/modules/guardrails2026-05-03
mpp-gatepreviewyesnonoyesno/api/agent-payments2026-05-03

Requires provider key means the module itself requires a provider credential to run. A non-cached LLM request still needs provider access unless it uses the managed MPP route.

Cloud-only / local-only

Most production modules work in both environments. A few have asymmetric capabilities:

ModuleCloudLocalNotes
cost-guardyespartialLocal has no hosted billing ledger; use it for estimate-based caps only.
usage-trackeryesnoCloud appends it automatically for billing/usage summaries.
mpp-gatepreviewnoMPP is a hosted payment surface.
airgapplannedplannedEnforce no-network-out at the gateway layer; use network policy today.
pattern-syncplannednoNeeds a cloud sync server.

See also