# Text Similarity – Cosine (Word-Count Vectors)

> Text Similarity – Cosine (Word-Count Vectors) 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 cosine similarity between two texts using word-count (bag-of-words) vectors, returning the similarity score, dot product, vector norms, and shared term count.

## Facts

- Endpoint: GET https://text-similarity.x402tookit.com/cosine-tokens?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-cosine-word-count-vectors-4e66d4c7
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_7CcYx0ZYy2972ISZaTGgB

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-cosine-word-count-vectors-4e66d4c7
```

Example prompt: Can you compute the cosine similarity between these two texts using word-count vectors? Text A: 'The quick brown fox jumps over the lazy dog' and Text B: 'A fast brown fox leaped over a sleepy dog' — treat them as case-insensitive.

## When to prefer this

Choose this endpoint when you need a lightweight, interpretable word-frequency-based similarity score — especially for duplicate detection, near-match filtering, or any task where term overlap matters more than semantic meaning. It is faster and cheaper than embedding-based similarity and produces transparent intermediate values (norms, dot product, shared terms) useful for debugging or ranking. Prefer it over Dice/Jaccard endpoints when you want a continuous similarity metric that accounts for term frequency rather than just presence/absence.

## Known failure modes

- Missing required query parameters 'a' or 'b' returns an error
- Texts exceeding 2000 characters may be rejected or truncated
- Empty strings produce a zero-norm vector making cosine undefined (likely returns null or 0)
- Payment failure (x402) prevents the call from completing
- Very short single-word inputs may yield low-signal results

## How this service works

Cosine similarity of the word-count vectors of two texts, with shared terms and vector norms.

## Output

Returns a JSON object containing the cosine similarity score (0–1), dot product of the two word-count vectors, L2 norms of each vector (normA, normB), number of shared terms, distinct token counts for each text, token counts, a human-readable summary and verdict, the ignoreCase setting used, and optional 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 (default) lowercases both texts first"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "dot": {
       "type": [
        "null",
        "number"
       ]
      },
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "normA": {
       "type": [
        "null",
        "number"
       ]
      },
      "normB": {
       "type": [
        "null",
        "number"
       ]
      },
      "cosine": {
       "type": [
        "null",
        "number"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "tokensA": {
       "type": [
        "null",
        "number"
       ]
      },
      "tokensB": {
       "type": [
        "null",
        "number"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "distinctA": {
       "type": [
        "null",
        "number"
       ]
      },
      "distinctB": {
       "type": [
        "null",
        "number"
       ]
      },
      "disclaimer": {
       "type": [
        "null",
        "string"
       ]
      },
      "ignoreCase": {
       "type": [
        "boolean",
        "null"
     
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/text-similarity-cosine-word-count-vectors-4e66d4c7/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)
