Skip to content

devmonrow/Monrow

Repository files navigation

Monrow

AI cost protection that runs inside your app.

Monrow wraps your Anthropic or OpenAI client in three lines, watches every AI call in-process, and throws an error before the next call fires when something goes wrong. No proxy. No latency. No background services.

npm install @monrow/sdk
import { Monrow, MonrowAbuseError } from '@monrow/sdk';
import Anthropic from '@anthropic-ai/sdk';

const monrow = new Monrow();
const anthropic = monrow.wrap(new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY }));

try {
  await anthropic.messages.create({
    model: 'claude-sonnet-4-5',
    monrow: { user: 'usr_bf29', feature: 'checkout-flow' },
    messages: [{ role: 'user', content: 'hello' }],
  });
} catch (err) {
  if (err instanceof MonrowAbuseError) {
    return cachedFallback(); // Monrow caught a runaway loop
  }
  throw err;
}

OpenAI support

import { Monrow, MonrowAbuseError } from '@monrow/sdk';
import OpenAI from 'openai';

const monrow = new Monrow();
const openai = monrow.wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));

try {
  await openai.chat.completions.create({
    model: 'gpt-4o',
    monrow: { user: 'usr_bf29', feature: 'checkout-flow' },
    messages: [{ role: 'user', content: 'hello' }],
  });
} catch (err) {
  if (err instanceof MonrowAbuseError) {
    return cachedFallback();
  }
  throw err;
}

Same detectors and local protection. Pro unlocks cost reports and incident history via the CLI.

What it does

Runaway loop detection. When a user fires 100 requests in 5 minutes, Monrow throws MonrowAbuseError before the next call. Your try/catch decides what to do — return a cached response, rate-limit the user, log and move on.

Cost ceiling enforcement. Set a per-user monthly spend limit. When they hit it, Monrow throws MonrowCostLimitError. No more power users costing more than they pay.

Velocity spike detection. When a user's request rate spikes 5× their baseline, Monrow logs the incident silently for your review.

Cost-per-feature tracking (Pro). Tag calls with a feature name. With a Pro API key, run npx monrow report --by-feature or use the monrow.io dashboard to see which parts of your product are quietly expensive.

Free (no account, no API key)

Install and protect. Detection runs entirely in-process — no network calls.

npx monrow doctor    # transparency report — always free

Runaway loop detection, cost ceilings, and velocity spike logging work without signing up.

Pro cloud ($29/mo)

Requires an account and API key in .monrowrc.json (get a key):

npx monrow report                 # cost per user (last 30 days)
npx monrow report --by-feature    # cost per feature
npx monrow incidents              # incident history
npx monrow incidents show <id>    # full incident detail

Also includes cross-server aggregation, cost-per-feature dashboard, real-time Slack/webhook alerts, AI margin intelligence, and the mobile panic surface at monrow.io/control — pause every server from your phone when something's wrong at 2am.

Security

Monrow never proxies your requests, collects prompt content, installs background services, or executes shell commands. Run npx monrow doctor to verify what it's doing on your machine.

Read SECURITY.md

Install

npm install @monrow/sdk

Peer dependencies: @anthropic-ai/sdk >= 0.30.0 or openai >= 4.0.0 — install whichever you use.

TypeScript, Node 18+.

Links

License

MIT — SDK only. The cloud dashboard is proprietary.

About

AI cost protection that runs inside your app. Stop runaway AI spend before it bankrupts you.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors