# Text Similarity: Longest Common Subsequence & Substring (LCS)

> Text Similarity: Longest Common Subsequence & Substring (LCS) 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 the longest common subsequence and longest common substring between two texts, returning their lengths, the actual sequences, start positions, and a 0-to-1 similarity ratio.

## Facts

- Endpoint: GET https://text-similarity.x402tookit.com/lcs?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-similarity-longest-common-subsequence-substring-lcs-94193c00
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_KQg0Nd3Rsbrv527_m6fAu

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-similarity-longest-common-subsequence-substring-lcs-94193c00
```

Example prompt: Find the longest common subsequence and substring between these two texts — 'The quick brown fox jumps over the lazy dog' and 'The slow brown fox leaped over a lazy cat' — and give me the similarity ratio, case-insensitively.

## When to prefer this

Choose this endpoint when you need classical sequence-level overlap metrics — specifically LCS subsequence and substring — rather than phonetic, edit-distance, or vector-space similarity. Ideal for detecting shared content spans, finding longest matching runs, or computing overlap ratios for document comparison pipelines where character-level alignment matters. Prefer sibling endpoints (Levenshtein, Dice, cosine) for edit-cost or set-overlap needs.

## Known failure modes

- Missing required query parameters 'a' or 'b' returns an error
- Inputs exceeding 2000 characters may be rejected or truncated
- Payment failure (x402 protocol) results in 402 Payment Required
- Empty strings may yield zero-length results with ratio 0
- Network timeout on large inputs close to the character limit

## How this service works

Longest common subsequence and longest common substring of two texts, with their lengths and a 0 to 1 ratio.

## Output

Returns the longest common subsequence string and its length, the longest common substring string with its length and start positions in both input texts, the character lengths of both inputs, the ignoreCase setting used, and a 0-to-1 similarity ratio reflecting overall overlap. May also include a summary, verdict, reasons, and degraded/disclaimer flags.

## 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": "First text, up to 2000 characters"
      },
      "b": {
       "type": "string",
       "description": "Second text, up to 2000 characters"
      },
      "ignoreCase": {
       "type": "boolean",
       "description": "true to compare case-insensitively (default false)"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "ratio": {
       "type": [
        "null",
        "number"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "lengthA": {
       "type": [
        "null",
        "number"
       ]
      },
      "lengthB": {
       "type": [
        "null",
        "number"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "substring": {
       "type": [
        "null",
        "string"
       ]
      },
      "disclaimer": {
       "type": [
        "null",
        "string"
       ]
      },
      "ignoreCase": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "notChecked": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "subsequence": {
       "type": [
        "null",
        "string"
       ]
      },
      "substringLength": {
       "type": [
        "null",
        "number"
       ]
   
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/text-similarity-longest-common-subsequence-substring-lcs-94193c00/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)
