AXIOM

AXIOM API Documentation

Encode text into 10,048-bit binary hypervectors. Compare anything to anything with a single similarity score.

API keys are provided on request. Replace YOUR_API_KEY in examples with your key.

Example Gallery

Browse by category. Every example is complete and runnable — copy, paste, and execute. Similarity scores shown are from real API responses.

String Matching

Fundamentals

Typo detection, fuzzy search, and near-duplicate string detection.

Typo detectionJavaScript
const API = "/api/encode";
const SIM = "/api/similarity";

// Encode the reference string and a string with a typo
const [refRes, typoRes] = await Promise.all([
  fetch(API, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ text: "hello world" }),
  }),
  fetch(API, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ text: "hello worl" }),  // missing 'd'
  }),
]);

const ref = await refRes.json();
const typo = await typoRes.json();

// Compare them
const sim = await fetch(SIM, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    vector_a: ref.vector,
    vector_b: typo.vector,
  }),
}).then(r => r.json());

console.log(sim.similarity);
Expected output
// "hello world" vs "hello worl" (one character removed)
{ "similarity": 0.8649 }

// High similarity means a likely typo, not a different string.
Fuzzy search — rank candidatesPython
import requests

API = "https://api.axiom.dev/v2"
KEY = "YOUR_API_KEY"
HEADERS = {"X-API-Key": KEY, "Content-Type": "application/json"}

query = "machine learning"
candidates = ["machine learning model", "rust programming", "quantum physics"]

# Batch-encode everything at once
all_texts = [query] + candidates
batch = requests.post(f"{API}/batch-encode",
                       headers=HEADERS,
                       json={"texts": all_texts}).json()

query_vec = batch["vectors"][0]["vector"]

# Score each candidate
for i, cand in enumerate(candidates, start=1):
    sim = requests.post(f"{API}/similarity",
                        headers=HEADERS,
                        json={"vector_a": query_vec,
                              "vector_b": batch["vectors"][i]["vector"]}).json()
    print(f'  "{cand}" → {sim["similarity"]}')
Expected output
  "machine learning model" → 0.8252
  "rust programming"      → ~0.50
  "quantum physics"        → ~0.50

# "machine learning model" is the clear best match.

Content Similarity

Popular

Compare sentences, match FAQs, and find related content.

Sentence comparisonJavaScript
// Compare two similar sentences (one word differs)
const texts = [
  "the cat sat on the mat",
  "the cat sat on the hat",
];

const batch = await fetch("/api/batch-encode", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ texts }),
}).then(r => r.json());

const sim = await fetch("/api/similarity", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    vector_a: batch.vectors[0].vector,
    vector_b: batch.vectors[1].vector,
  }),
}).then(r => r.json());

console.log(`Similarity: ${sim.similarity}`);
Expected output
Similarity: 0.8547

// One word changed ("mat" → "hat") — still very high similarity.
FAQ matching — find closest questionPython
import requests

API = "https://api.axiom.dev/v2"
KEY = "YOUR_API_KEY"
HEADERS = {"X-API-Key": KEY, "Content-Type": "application/json"}

faqs = [
    "How do I reset my password?",
    "What is machine learning?",
    "How do I cancel my subscription?",
]
user_question = "machine learning model"

# Encode all at once: user question first, then FAQs
all_texts = [user_question] + faqs
batch = requests.post(f"{API}/batch-encode",
                       headers=HEADERS,
                       json={"texts": all_texts}).json()

user_vec = batch["vectors"][0]["vector"]

best_score, best_faq = 0, ""
for i, faq in enumerate(faqs, start=1):
    sim = requests.post(f"{API}/similarity",
                        headers=HEADERS,
                        json={"vector_a": user_vec,
                              "vector_b": batch["vectors"][i]["vector"]}).json()
    score = sim["similarity"]
    print(f"  {score:.4f}  {faq}")
    if score > best_score:
        best_score, best_faq = score, faq

print(f"\nBest match: {best_faq}")
Expected output
  ~0.50   How do I reset my password?
  0.8252  What is machine learning?
  ~0.50   How do I cancel my subscription?

Best match: What is machine learning?

Data Deduplication

Data Ops

Find near-duplicate entries in a dataset.

Pairwise duplicate checkJavaScript
const entries = [
  "hello world",
  "hello worl",       // typo duplicate
  "rust programming",
  "python programming",
  "dog",
];

// Batch encode
const batch = await fetch("/api/batch-encode", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ texts: entries }),
}).then(r => r.json());

const THRESHOLD = 0.75;  // similarity above this = likely duplicate

// Compare every pair
for (let i = 0; i < entries.length; i++) {
  for (let j = i + 1; j < entries.length; j++) {
    const sim = await fetch("/api/similarity", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        vector_a: batch.vectors[i].vector,
        vector_b: batch.vectors[j].vector,
      }),
    }).then(r => r.json());

    if (sim.similarity >= THRESHOLD) {
      console.log(
        `DUPLICATE: "${entries[i]}" ↔ "${entries[j]}" → ${sim.similarity}`
      );
    }
  }
}
Expected output
DUPLICATE: "hello world" ↔ "hello worl" → 0.8649
DUPLICATE: "rust programming" ↔ "python programming" → 0.7481

// "dog" has no near-duplicate above 0.75.
// Adjust THRESHOLD to control sensitivity.

Search & Retrieval

Search

Build a simple semantic-ish search engine with AXIOM vectors.

Mini search enginePython
import requests

API = "https://api.axiom.dev/v2"
KEY = "YOUR_API_KEY"
HEADERS = {"X-API-Key": KEY, "Content-Type": "application/json"}

# Corpus (pre-index in a real app)
corpus = [
    "the cat sat on the mat",
    "the cat sat on the hat",
    "machine learning model",
    "rust programming",
    "hello world",
]

query = "the cat sat on the mat"

# Encode query + corpus in one batch
all_texts = [query] + corpus
batch = requests.post(f"{API}/batch-encode",
                       headers=HEADERS,
                       json={"texts": all_texts}).json()

query_vec = batch["vectors"][0]["vector"]

# Rank by similarity
results = []
for i, doc in enumerate(corpus, start=1):
    sim = requests.post(f"{API}/similarity",
                        headers=HEADERS,
                        json={"vector_a": query_vec,
                              "vector_b": batch["vectors"][i]["vector"]}).json()
    results.append((sim["similarity"], doc))

results.sort(reverse=True)
for score, doc in results:
    print(f"  {score:.4f}  {doc}")
Expected output
  1.0000  the cat sat on the mat       ← exact match
  0.8547  the cat sat on the hat       ← one word different
  ~0.50   machine learning model
  ~0.50   rust programming
  ~0.50   hello world

Classification

ML Lite

Categorize text by comparing it to category prototype strings.

Zero-shot text classificationJavaScript
// Define category prototypes
const categories = {
  "Animals":     "dog cat pet animal",
  "Tech":        "machine learning programming code",
  "Greetings":   "hello world hi greeting",
};

const textToClassify = "running";

// Encode everything
const allTexts = [textToClassify, ...Object.values(categories)];
const batch = await fetch("/api/batch-encode", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ texts: allTexts }),
}).then(r => r.json());

const inputVec = batch.vectors[0].vector;
const labels = Object.keys(categories);

let bestLabel = "", bestScore = 0;
for (let i = 0; i < labels.length; i++) {
  const sim = await fetch("/api/similarity", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      vector_a: inputVec,
      vector_b: batch.vectors[i + 1].vector,
    }),
  }).then(r => r.json());

  console.log(`  ${labels[i]}: ${sim.similarity.toFixed(4)}`);
  if (sim.similarity > bestScore) {
    bestScore = sim.similarity;
    bestLabel = labels[i];
  }
}
console.log(`\nClassified as: ${bestLabel}`);
Expected output
  Animals:   ~0.52
  Tech:      ~0.50
  Greetings: ~0.50

Classified as: Animals

// "running" has a slight affinity to "Animals" (runner → animal activity).
// Use multiple prototype strings per category for better accuracy.

Monitoring & Alerting

Ops

Detect content drift and anomalies by tracking similarity over time.

Content drift detectionPython
import requests

API = "https://api.axiom.dev/v2"
KEY = "YOUR_API_KEY"
HEADERS = {"X-API-Key": KEY, "Content-Type": "application/json"}

# Baseline: the "expected" content
baseline_text = "apple"

# Incoming versions to monitor
incoming = [
    "apple",            # no change
    "application",      # drifted
    "quantum physics",  # completely different
]

# Encode baseline + all incoming
all_texts = [baseline_text] + incoming
batch = requests.post(f"{API}/batch-encode",
                       headers=HEADERS,
                       json={"texts": all_texts}).json()

baseline_vec = batch["vectors"][0]["vector"]
DRIFT_THRESHOLD = 0.70

for i, text in enumerate(incoming, start=1):
    sim = requests.post(f"{API}/similarity",
                        headers=HEADERS,
                        json={"vector_a": baseline_vec,
                              "vector_b": batch["vectors"][i]["vector"]}).json()
    score = sim["similarity"]
    status = "OK" if score >= DRIFT_THRESHOLD else "ALERT"
    print(f"  [{status}] {score:.4f}  \"{text}\"")
Expected output
  [OK]    1.0000  "apple"            ← identical
  [ALERT] 0.6391  "application"      ← shares prefix but drifted
  [ALERT] ~0.50   "quantum physics"  ← completely unrelated

// Set DRIFT_THRESHOLD based on your tolerance.

SDK Quick Start

Minimal copy-paste snippets to make your first API call.

cURLbash
# Encode a string
curl -X POST https://api.axiom.dev/v2/encode \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{"text": "hello world"}'

# Health check (no key needed)
curl https://api.axiom.dev/v2/health
Expected output
{
  "text": "hello world",
  "vector": [147, 68, 33, ...],   // 1,256 bytes
  "dimensions": 10048
}
JavaScript (fetch)JavaScript
const BASE = "https://api.axiom.dev/v2";
const KEY  = "YOUR_API_KEY";

async function encode(text) {
  const res = await fetch(`${BASE}/encode`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-API-Key": KEY,
    },
    body: JSON.stringify({ text }),
  });
  return res.json();
}

async function similarity(vectorA, vectorB) {
  const res = await fetch(`${BASE}/similarity`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-API-Key": KEY,
    },
    body: JSON.stringify({ vector_a: vectorA, vector_b: vectorB }),
  });
  return res.json();
}

// Usage
const a = await encode("hello world");
const b = await encode("hello world");
const sim = await similarity(a.vector, b.vector);
console.log(sim.similarity); // 1.0000
Expected output
{ "similarity": 1.0000 }

// Identical strings always produce identical vectors.
Python (requests)Python
import requests

API = "https://api.axiom.dev/v2"
KEY = "YOUR_API_KEY"
HEADERS = {"X-API-Key": KEY, "Content-Type": "application/json"}

def encode(text):
    return requests.post(f"{API}/encode",
                         headers=HEADERS,
                         json={"text": text}).json()

def similarity(vec_a, vec_b):
    return requests.post(f"{API}/similarity",
                         headers=HEADERS,
                         json={"vector_a": vec_a, "vector_b": vec_b}).json()

a = encode("dog")
b = encode("cat")
print(similarity(a["vector"], b["vector"]))
Expected output
{"similarity": 0.5012}

# "dog" vs "cat" — short unrelated words sit near the random baseline (~0.50).