# AI Regex Generator and Tester

> AI Regex Generator and Tester is a paid API for AI agents from twin.unykorn.org, paid per call via x402, $0.005/call, status unknown (last checked 2026-10-02).

Generates a regular expression from a plain-language description and validates it against user-supplied match/no-match examples

## Facts

- Endpoint: POST https://twin.unykorn.org/ai/regex?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/ai-regex-generator-and-tester-3d8bb4a5
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_w4Djgluj0iHckgiBPxmTm

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability ai-regex-generator-and-tester-3d8bb4a5 -d '<json body>'
```

Example prompt: Generate a JavaScript regex that matches valid email addresses, and test it — the pattern should match 'user@example.com' and 'hello+tag@sub.domain.org', but not 'notanemail' or 'missing@'

## When to prefer this

Choose this endpoint when you need to both generate and immediately validate a regular expression in one step, especially when you have concrete positive and negative examples to test against. It is ideal for agents automating code generation, data validation pipelines, or form input validation where correctness must be confirmed before use. Prefer this over a plain LLM regex request when test-driven verification of the output matters.

## Known failure modes

- Description too vague or contradictory — may produce a regex that doesn't correctly reflect intent
- Conflicting match/no-match examples — endpoint may fail or return a best-effort pattern
- Description exceeds 500 character limit — request rejected
- More than 10 examples in should_match or should_not_match — request rejected
- Unsupported flavor value — falls back to JavaScript default
- Network or payment failure — returns 402 or connection error

## How this service works

Generate a regex from a description and TEST it against your examples — Genesis402 / UnyKorn Operator Network

## Output

Returns a generated regular expression matching the given description, plus test results showing which provided examples matched and which did not, allowing immediate verification of the pattern's correctness.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "params": {
   "type": "object",
   "properties": {
    "flavor": {
     "type": "string",
     "description": "optional: javascript (default) | python | pcre"
    },
    "description": {
     "type": "string",
     "description": "required, up to 500 chars"
    },
    "should_match": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "maxItems": 10,
     "description": "optional up to 10 examples"
    },
    "should_not_match": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "maxItems": 10,
     "description": "optional up to 10 examples"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "ok": true,
  "type": "regex-generate",
  "receipt": {
   "tx_hash": "0x<64hex>",
   "amount_usd": 0.005,
   "receipt_id": "g402-<16hex>"
  },
  "sources": [
   {
    "ok": true,
    "name": "<source>"
   }
  ],
  "limitations": "<text>",
  "generated_at": "<iso time>",
  "evidence_hash": "sha256:<64hex>"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/ai-regex-generator-and-tester-3d8bb4a5/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from twin.unykorn.org](https://www.zero.xyz/host/twin.unykorn.org/llms.txt)
