Early Access Beta: free, no credit card needed. Sign up →

Ordainer vs building it yourself

The situation

Your plans say how much each customer gets. Your customers' scripts and AI agents don't read them. So you need a check that says no to the one key that is over its allowance.

Most engineering teams can build that. A counter in Redis or Postgres, a middleware, a table of plans. This page is an honest look at what building it yourself involves, what Ordainer does for you, and when building it yourself is the right call.

What you'd build

1. Keys and plans. One key per customer integration or AI agent, bound to one customer and one plan. A plan holds an allowance, a period and a tool rule. You also need a way to create, move and revoke keys, and a way to edit a plan while customers are using it.

2. A counter that holds under load. The check and the count have to be one step. If two calls arrive together at the last allowed slot, only one may get it. A read then a write isn't enough.

3. Period resets. A month, a day or a minute, with a clear time zone. Ordainer resets in UTC. Old counters need cleaning up. A plan edit in the middle of a period needs a rule: in Ordainer, the count belongs to the key, so it carries over a cap change, and the new cap applies from the next decision.

4. Idempotency. Agents and SDKs retry. A retry must not use up allowance twice. In Ordainer, a call with the same idempotency key gets the stored answer back for 24 hours, and no counter moves. The same key with a different tool is refused.

5. Audit rows. One row per decision: which key, which customer, which tool, allow or deny, why, and what was left. You also want to look up one decision by its request ID, export a date range, and decide how long to keep rows. In Ordainer, every decision has a request ID that matches the row in the console and the export, and you can download decisions as CSV or JSON.

6. Shadow mode. Before you block real customers, you want to see who would be blocked. That is a mode flag on the plan, a log of would-deny decisions that doesn't block, and a way to flip it to enforce without a deploy. Ordainer plans you create in the console start in shadow.

7. A deny your callers can read. An AI agent that gets a bare error may keep retrying. A good deny says the limit was reached, when it resets, and that retrying before then won't work. The Ordainer SDKs give you a ready-made response with that.

8. Failure handling. Decide what happens when your counter store is slow or down: let the call run, or stop it. In Ordainer's SDKs the default is to let the call run and log a warning, and you can set a client, route or call to block instead.

9. Admin tools. A console, or an API, to add customers, plans and keys, and to watch usage. Ordainer has a console, an admin API, and an MCP server (ordainer-mcp 0.1.1) that lets an AI coding agent set up customers, plans and test keys.

None of it is exotic. It is a lot of small things that each have a sharp edge, and they are yours to maintain.

What Ordainer does instead

At the top of your handler, send the caller's agent key and the tool name to decide(). Ordainer checks that key's plan, answers allow or deny, counts the call in the same step, and writes one audit row. In enforce mode, on a deny, you skip the work. SDKs are available for Node (1.4.0), Python (0.4.0), Ruby (0.1.3) and Java (0.1.0), and plain HTTP works from any language, including an MCP tool handler. Your traffic doesn't pass through us.

What you take on by using it

  • A hosted dependency. The check is a network call. If we can't answer, the SDKs let your tool run by default and log a warning, or you can set a client, route or call to block.
  • A beta product. During the beta you use test keys, and live keys are not available yet. All test keys in your organization share one allowance of allowed test decisions each month: 1,000 on a standard sign-up.
  • Limits you may not want. Ordainer counts calls, not dollars or tokens. Each key counts on its own, and one cap covering all of a customer's keys together isn't available today. It doesn't send usage to a billing system.
  • Not a rate limiter. If you need to protect your servers from bursts, keep your own rate limits.

When building it yourself is fine

Building your own is a good choice when:

  • You have one service, one tool and a handful of customers, and you already run a counter store.
  • You need a limit shared across all of a customer's keys, or a limit in dollars or tokens. Ordainer doesn't do those today.
  • You can't send any call to an outside service.
  • You only need to protect your servers. That is a rate limit, and your gateway, proxy or framework already has one.
  • You want the logic in your own code, and keeping it up to date is part of the job you want.

Ordainer is worth a look when you have many integrations and AI agents, you want an audit row for every decision, you want a shadow mode before you enforce, or you'd rather not own the counters, the resets and the retries. You can also try both: run Ordainer in shadow mode for a while, read the would-deny counts, and decide from real numbers.

Common questions

Why not just count requests in Redis?

You can, and for one service it can be enough. The parts that tend to bite are the ones above: holding the count under simultaneous calls, retries that must not count twice, period resets, and a record of every decision. Ordainer does those as one decide() call.

Can I leave later?

Yes. Your handlers call decide() in one place each, and you can export your decisions as CSV or JSON from the console. Moving to your own counters means replacing those calls with your own check.

Does it replace my rate limits?

No. Ordainer is not a rate limiter. Keep your own rate limits for traffic spikes and use Ordainer for the plan each key is on.

Does it work for AI agents and ordinary API integrations?

Yes, both. Give each integration or agent its own agent key on a plan. For MCP, call decide() at the top of each tool handler.

Try it

Ordainer is free during the beta: sign up for test keys with 1,000 decisions a month, no credit card needed.

Get test keys · Produce a deny in the live demo

Built your own and want to compare notes? We'd like to hear what you learned: support@ordainer.ai.