# 24KLabs Text Diff

> 24KLabs Text Diff is a paid API for AI agents from api.24klabs.ai, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-13).

Computes a unified diff between two text strings, returning added/removed line counts and a similarity ratio.

## Facts

- Endpoint: POST https://api.24klabs.ai/api/v1/text-diff
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/24klabs-text-diff-5ffe70bf
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_i7BDTd8uuAtMePweUzgKM

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 24klabs-text-diff-5ffe70bf -d '<json body>'
```

Example prompt: Can you diff these two versions of my README and tell me what lines were added, what was removed, and how similar they are overall? Here's the original: 'Welcome to MyApp. Install with npm install.' And here's the new version: 'Welcome to MyApp v2. Install with npm install myapp. See docs for more.'

## When to prefer this

Choose this endpoint when you need a structured, machine-readable diff with similarity scoring between two arbitrary text strings — particularly when you need both the unified diff format and quantitative change metrics (line counts + ratio) in a single call, without setting up a local diff library.

## Known failure modes

- Missing or empty input texts return a 400 error
- Extremely large texts may time out or be rejected
- Non-UTF-8 encoded content may cause parsing errors
- Both texts identical returns zero diff with similarity ratio of 1.0

## How this service works

Unified diff between two texts, plus added/removed line counts and a similarity ratio.

## Output

Returns a unified diff string showing line-level changes between the two input texts, a count of added lines, a count of removed lines, and a floating-point similarity ratio (0–1) indicating how alike the two texts are.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "a": {
   "type": "string"
  },
  "b": {
   "type": "string"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "similarity": 0.8
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/24klabs-text-diff-5ffe70bf/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.24klabs.ai](https://www.zero.xyz/host/api.24klabs.ai/llms.txt)
