Request access

runlawYour rules on every AI call

The top of the Code of Hammurabi stele in the Louvre: a king stands before a seated god, above columns of carved law
Close detail of the stele's cuneiform: rows of laws cut into black stone

Write the rules your models and agents must follow. runlaw enforces them on every call, before anything reaches your users.

Every ruling is written down: the rule, the evidence and the outcome. Try one

How you set your rules

  1. Ten minutesFirst, write the policy: a list of rules in JSON, in the console or with one PUT /api/policy.
  2. SecondsThen replay it against your last 50 real calls and read what it would have changed.
  3. A week in monitorNext, save it in monitor mode. Every ruling is recorded and nothing is changed yet.
  4. Every call afterFinally, switch to enforce. Each save is a version you can restore in one click.

Edit any rule. The call on the right is ruled again as you type.

Write a rule,

Ruling…
    Forwarded to the model

    Two calls to start

    Save your policy once. Then point any OpenAI client at runlaw. Your code does not change, and every call is ruled under the policy you saved.

    Save the policy for your workspace

    curl -X PUT https://runlaw.jacobfv123.workers.dev/api/policy \
      -H "Authorization: Bearer $RUNLAW_KEY" \
      -H "Content-Type: application/json" \
      -d '{"note": "Refunds over $500 need a person",
           "policy": {"name": "support", "mode": "monitor",
             "rules": [{"id": "refund-limit", "type": "tool",
               "on": ["tool_call"], "tool": "issue_refund",
               "when": {"arg": "amount", "op": ">", "value": 500},
               "action": "require_approval"}]}}'

    Send calls through it

    from openai import OpenAI
    
    client = OpenAI(
        base_url="https://runlaw.jacobfv123.workers.dev/v1",
        api_key=os.environ["RUNLAW_KEY"],
    )
    client.chat.completions.create(model="gpt-6-luna", messages=messages, tools=tools)

    Prefer a screen? The console's Policy page has the same editor, the replay, and every saved version. Read the policy reference

    What a rule can do

    A rule can redact [card] a card number before the model sees it, hold held a large refund for a person, block blocked a pasted secret, or rewrite rewritten advice it should not give.

    Rules on personal data, text patterns and tool arguments are exact: the amount is over the line or it isn't. Rules written in plain words are judged by a model, and each ruling records its confidence.

    See the rule types
    A telephone switchboard operator at work, 1925
    Card numbers and emails are redacted before the model sees them, and promises of refunds are rewritten.
    A 1920s bank tellers' cage of carved wood and brass bars
    Payments over $1,000 wait for a person. Over $25,000, they are refused outright.
    A hospital nurses' station at the end of a long corridor
    Patient identifiers never reach the model, and answers that diagnose are rewritten.
    Two programmers setting up ENIAC by its plugboards, 1946
    Keys pasted into prompts are blocked, and destructive shell commands are held.
    Readers at the desks of an international law reading room, 1964
    Specific legal advice is rewritten into general information, with the ruling on file.
    A large typing pool at the Navy Department, Washington, 1918
    Salaries and staff records stay out of answers, and every request is logged.

    Every call is on the record

    Server racks in a data centre

    One call, ruled

    The trace of a call whose refund was held
    Received2 messages, 1 tool offered0 ms
    Inputredact-pii: card number and email replaced3 ms
    Inputno-prompt-extraction: passed, 0.99, monitor412 ms
    Modelproposed issue_refund, amount 1,2402,318 ms
    Tool callrefund-limit: 1,240 is over 500, held2,319 ms
    Approvalsqueued for a person to approve or deny2,319 ms
    Returneda notice in place of the tool call3,242 ms
    Storedoriginal request, forwarded request, both responsesTrace API

    Plain answers

    How do I set my policy? Write it as JSON and save it in the console's Policy page, or send it with PUT /api/policy. Each save is a new version; the newest is live for every call in your workspace.

    Can a rule be written in plain words? Yes. A semantic rule is one sentence, such as "the answer gives specific legal advice". A model judges each call against it and records its confidence; you set the threshold.

    Is enforcement guaranteed? Exact rules on personal data, patterns and tool arguments are deterministic. Plain-word rules are a model's judgement and can be wrong, so run them in monitor mode first.

    Can it see my model's hidden reasoning? No. runlaw sees what passes through the gateway: the request, the response and the tool calls the model proposes.

    What about tools my agent runs itself? runlaw rules on a tool call as the model proposes it, before your code runs it. What your code does afterwards happens outside the gateway.

    Does streaming work? Yes, as standard server-sent events. The answer is checked whole before it is sent, so the first token arrives when the full answer is ready.

    How much latency does it add? Exact rules add under a millisecond. Plain-word input rules are judged while the model answers, so they usually add nothing; output rules add one round of judge calls, run in parallel, about 0.9 seconds with the default judge in our latest evaluation.

    What if the judge is unavailable? Your policy decides: allow the call and record the error, or block it. The trace says which happened.

    What does it cost? Usage is counted in credits: one credit is 1,000 tokens, the judge's included. New accounts start with 1,000 credits.

    Which models can I use? Any model your OpenAI key can call, through the standard chat completions API.

    Put your rules in writing

    runlaw is in early access. Leave your work email and we'll set up a 20-minute onboarding call to walk through your agents and your first policy. Already have an account? Sign in.