# Text Diff (Word/Line)

> Text Diff (Word/Line) is a paid API for AI agents from text-similarity.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-21).

Computes a diff of two short texts into equal, inserted, and deleted segments at word or line granularity, returning counts and a similarity ratio.

## Facts

- Endpoint: GET https://text-similarity.x402tookit.com/text-diff?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-21
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/text-diff-word-line-39068653
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_OL9Yy07fTNUL-jMXCBvAj

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 text-diff-word-line-39068653
```

Example prompt: Compare these two paragraphs word by word and tell me what was added, removed, and unchanged, plus how similar they are: original is 'The quick brown fox jumps over the lazy dog' and the new version is 'The quick red fox leaps over a sleepy dog'.

## When to prefer this

Choose this endpoint when you need a structured, token-level breakdown of differences between two short texts — not just a similarity score but the actual edit operations (what was added, deleted, kept). It is ideal when you need both the diff sequence and a similarity ratio in a single call. Prefer it over pure similarity endpoints (Levenshtein, cosine, Jaro-Winkler) when the agent needs to explain or display what changed, not just how different the texts are. Best for texts up to 2000 characters each.

## Known failure modes

- Missing required parameters 'a' or 'b' returns an error
- Input text exceeding 2000 characters per field may be rejected or truncated
- Invalid 'unit' enum value (not 'word' or 'line') returns a validation error
- Empty strings for both inputs may return a trivial result with ratio 1.0 or 0.0
- Payment failure (x402) results in 402 response and no diff is returned

## How this service works

Diff of two short texts into equal, deleted and inserted lines or words, with counts and a similarity ratio.

## Output

Returns a structured diff with an array of edit operations (each tagged as equal, insert, or delete with the affected text and token count), total added/removed/unchanged unit counts, word or character counts for each input text, an overall similarity ratio between 0 and 1, a human-readable summary and verdict, and metadata like the diff unit and timestamp.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "a",
      "b"
     ],
     "properties": {
      "a": {
       "type": "string",
       "description": "Original text, up to 2000 characters"
      },
      "b": {
       "type": "string",
       "description": "New text, up to 2000 characters"
      },
      "unit": {
       "enum": [
        "word",
        "line"
       ],
       "type": "string",
       "description": "word (default) or line"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "unit": {
       "type": [
        "null",
        "string"
       ]
      },
      "added": {
       "type": [
        "null",
        "number"
       ]
      },
      "edits": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "object",
        "properties": {
         "op": {
          "type": [
           "null",
           "string"
          ]
         },
         "text": {
          "type": [
           "null",
           "string"
          ]
         },
         "count": {
          "type": [
           "null",
           "number"
          ]
         }
        }
       }
      },
      "ratio": {
       "type": [
        "null",
        "number"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "unitsA": {
       "type": [
        "null",
        "number"
       ]
      },
      "unitsB": {
       "type": [
        "null",
        "number"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "removed": {
       "type": [
        "null",
        "number"
       ]
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict"
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/text-diff-word-line-39068653/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from text-similarity.x402tookit.com](https://www.zero.xyz/host/text-similarity.x402tookit.com/llms.txt)
