x402AgentTools

๐Ÿ”€Text Diff

Compare two texts line by line using an LCS diff: exact additions, removals and context โ€” in unified-diff style. Deterministic, unlike asking a model to 'find the differences'.

Worked examples

One line changed

GET /api/v1/dev/diff?a=price%3A%20100%0Aquantity%3A%202%0Atotal%3A%20200&b=price%3A%20100%0Aquantity%3A%203%0Atotal%3A%20300&context=1

Result: +2 / โˆ’2 lines

Line added and removed

GET /api/v1/dev/diff?a=alpha%0Abeta%0Agamma&b=alpha%0Adelta%0Agamma%0Aepsilon&context=1

Result: +2 / โˆ’1 lines

Identical inputs

GET /api/v1/dev/diff?a=same%0Alines&b=same%0Alines

Result: Inputs are identical

Machine API (x402)

$0.002 / call

This tool is also a JSON API for AI agents. Requests without payment receive 402 Payment Required plus instructions; agents pay USDC on Base via the x402 protocol โ€” no accounts, no API keys.

GET /api/v1/dev/diff?a=price%3A%20100%0Aquantity%3A%202%0Atotal%3A%20200&b=price%3A%20100%0Aquantity%3A%203%0Atotal%3A%20300&context=1 HTTP/1.1
Host: agenttools-hub.vercel.app

โ†’ 402 (payment required, instructions in headers)
โ†’ 200 (after X-PAYMENT header; JSON body below)

{
  "tool": "dev/diff",
  "input": {"a":"price: 100\nquantity: 2\ntotal: 200","b":"price: 100\nquantity: 3\ntotal: 300","context":1},
  "result": { "value": 4, "answer": "+2 / โˆ’2 lines" }
}

Agent docs: /llms.txt ยท OpenAPI spec ยท integration guide

About this tool

A real LCS diff: the full text goes in, an exact unified-style diff comes out in `result.artifacts.diff` โ€” additions, removals and context lines, identical every time. The reliable alternative to asking a language model to eyeball two texts.

Frequently asked questions

How large can the inputs be?

The DP table caps around 5,000 lines per side; larger inputs are rejected with a clear error rather than hanging.

Is it compatible with `git diff`?

It's unified-style (space/-/+ prefixes, context windows) โ€” great for humans and agents. It omits @@ hunk headers, so it isn't a strict patch file.

Related tools