# Criteria Checker: AI QA Gate for Emails & LLM Output (`ferrolark/criteria-checker`) Actor

Pass/fail AI QA gate for automations: check text or JSON against templates or your own criteria with calibrated probabilities. Thresholds, review band and a report. Built-in classification engine, no external API key needed. For n8n, Make and MCP.

- **URL**: https://apify.com/ferrolark/criteria-checker.md
- **Developed by:** [Ferrolark](https://apify.com/ferrolark) (community)
- **Categories:** AI, Automation, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.50 / 1,000 criterion evaluateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Criteria Checker: AI QA Gate for Content, Emails & LLM Output

A pass / fail gate for your automations. Send a text or JSON (an AI-written email, a support reply, a blog post, an LLM answer) and get a verdict per criterion and an overall **pass, review or fail**, with calibrated probabilities instead of a "looks good to me" from a chat model.

- **Ready templates:** `email-before-send`, `llm-answer-grounded`, `support-reply`, `blog-post-prepublish`, `product-description`, `social-post`. Each bundles checks such as leftover `{{placeholders}}`, "as an AI language model" text, unsupported claims, tone and missing call to action.
- **Your own criteria:** yes/no questions, graded scores (2-10 levels) or choices, with per-criterion thresholds, weights, required flags and minimum confidence.
- **Three outcomes, not two:** answers close to the threshold become `review`, so uncertain items go to a person instead of slipping through. `failClosed` turns review into fail.
- **Decision in code:** `all_required` or a weighted score with a minimum; output gives `failedIds` and `reviewIds` you can branch on in n8n, Make or your app.
- **Batch:** up to 100 items per run (20,000 characters each), with a `REPORT.md` summary (pass rates per criterion and the items to look at).

Classification runs on Ferrolark's built-in calibrated engine (Jev). **You do not need an external API key.**

### Example

```json
{
  "template": "email-before-send",
  "state": "Hi {{first_name}},\n\nAs an AI language model, I've drafted this follow-up for you...",
  "criteria": [{"id": "mentions_price", "instructions": "Does the email mention a price?", "required": false}]
}
```

Each dataset row is one checked item:

```json
{"id": "state-1", "overall": "fail", "overallPass": false, "failedIds": ["no_placeholders", "no_ai_meta"], "reviewIds": [],
 "results": [{"id": "no_placeholders", "label": "No placeholder or template text", "verdict": "fail", "reasonCode": "statement_true"}], "inputTokens": 410}
```

### Price

- **$0.0005 per criterion evaluated** (a 7-criterion template costs $0.0035 per item; 1,000 emails ≈ $3.50).
- Not charged: invalid input or engine errors before a successful classification.
- Classification cost is included in the event price (no separate API key billing for you).

### Input

| Field | Default | What it does |
|---|---|---|
| `state` / `reference` | none | The content, and optional source or question it must match. |
| `items` | none | Batch: `[{"id", "state", "reference"}]`, up to 100. |
| `template` | `email-before-send` | A criteria set, or `none`. |
| `criteria` / `disableCriteria` | none | Add or replace criteria; switch off template ones. |
| `noulThreshold` / `reviewBand` | 0.7 / 0.2 | Default pass probability and the review zone below it. |
| `policy` / `minWeightedScore` | `all_required` / 0.8 | Overall rule. |
| `failClosed` | `false` | Review counts as fail. |
| `model` | `jev-latest` | Pin a version when you tune thresholds. |

### Call it from code, n8n or an AI agent

```bash
curl -X POST "https://api.apify.com/v2/acts/ferrolark~criteria-checker/run-sync-get-dataset-items?maxTotalChargeUsd=0.05" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
  -d '{"template": "support-reply", "state": "We have re-sent your order.", "reference": "Where is my order?"}'
```

In n8n, put an HTTP Request node before your "send" step and an IF node on `overall == "pass"`.

### FAQ

**Do I need a TypeSafe or OpenAI key?**

No. Classification is built in and included in the event price.

**Does it decide for me?**

It decides by rules you control. The probabilities come from the classification engine; the thresholds and policy are yours. Use the review band for anything costly.

### More Ferrolark tools

- [Brand Name Availability Checker](https://apify.com/ferrolark/brand-name-checker)
- [Domain Intelligence Report](https://apify.com/ferrolark/domain-intelligence-report)
- [Support Ticket Triage](https://apify.com/ferrolark/ticket-triage)
- [Amazon Listing Checker](https://apify.com/ferrolark/amazon-listing-rules)

***

*Built by Ferrolark.*

# Actor input Schema

## `state` (type: `string`):

The text to check, for example an AI-written email or answer. For many items use 'items'.

## `reference` (type: `string`):

Source material, the question asked, or the customer message the content must match. Needed by llm-answer-grounded and support-reply.

## `template` (type: `string`):

A ready set of criteria. Add your own below; a custom criterion with the same id replaces the template's.

## `criteria` (type: `array`):

List of {"id", "instructions", "type": "noul"|"score"|"choice", ...}. Noul: passThreshold (0.7), passWhenFalse. Score: criteria (levels low to high), scorePassMin. Choice: criteria (map), passOptions, minProbability. Any: required, weight, minConfidence, severity.

## `disableCriteria` (type: `array`):

Template criterion ids to skip.

## `items` (type: `array`):

Up to 100 items: \[{"id": "msg-1", "state": "...", "reference": "..."}]. One classification request per item (max 20,000 characters each).

## `noulThreshold` (type: `string`):

Probability needed to pass. Raise it where a wrong pass is expensive.

## `reviewBand` (type: `string`):

Answers this far below the threshold are 'review' instead of 'fail'.

## `policy` (type: `string`):

How the overall result is computed.

## `minWeightedScore` (type: `string`):

For the weighted rule (0 to 1).

## `failClosed` (type: `boolean`):

For gates where nothing uncertain may pass.

## `model` (type: `string`):

Classification model alias (default jev-latest). Pin a version such as jev-1.14.0 when you tune thresholds.

## `concurrency` (type: `integer`):

Parallel classification requests (capped at 4).

## Actor input object example

```json
{
  "state": "Hi {{first_name}},\n\nAs an AI language model, I've drafted this follow-up for you. Our plan costs $49/month. Reply to book a demo!",
  "template": "email-before-send",
  "criteria": [
    {
      "id": "mentions_price",
      "instructions": "Does the email mention a price?",
      "required": false
    }
  ],
  "noulThreshold": "0.7",
  "reviewBand": "0.2",
  "policy": "all_required",
  "minWeightedScore": "0.8",
  "failClosed": false,
  "model": "jev-latest",
  "concurrency": 4
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "state": `Hi {{first_name}},

As an AI language model, I've drafted this follow-up for you. Our plan costs $49/month. Reply to book a demo!`,
    "criteria": [
        {
            "id": "mentions_price",
            "instructions": "Does the email mention a price?",
            "required": false
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ferrolark/criteria-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "state": """Hi {{first_name}},

As an AI language model, I've drafted this follow-up for you. Our plan costs $49/month. Reply to book a demo!""",
    "criteria": [{
            "id": "mentions_price",
            "instructions": "Does the email mention a price?",
            "required": False,
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("ferrolark/criteria-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "state": "Hi {{first_name}},\\n\\nAs an AI language model, I'\''ve drafted this follow-up for you. Our plan costs $49/month. Reply to book a demo!",
  "criteria": [
    {
      "id": "mentions_price",
      "instructions": "Does the email mention a price?",
      "required": false
    }
  ]
}' |
apify call ferrolark/criteria-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ferrolark/criteria-checker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hNZrXvjWkCjZKLQRW/builds/cEs9sntHqwdiPw0pJ/openapi.json
