WCAG 2.2 contrast check with the minimal OKLCH lightness fix and colour-blind pair check

$0.005 USDC per call · Business, finance and compliance · POST /api/v1/contrast-fix · Id contrast-fix

Checks up to 50 foreground/background hex pairs against a WCAG 2.2 contrast threshold (4.5 AA text, 3 large text and UI, 7 AAA, or your own) on the unrounded ratio, so 4.499 fails and exactly 4.5 passes, and for a failing pair returns the closest colour by OKLCH lightness (chroma and hue held, gamut-clipped, 8-bit) that meets it. Optionally simulates protanomaly, deuteranomaly and tritanomaly (Machado et al. 2009, any severity, 1.0 is dichromacy) and reports whether the pair stays distinguishable by OKLab distance against your threshold. Built for designers and agents generating palettes. It does not evaluate APCA, text size or weight, opacity, images, gradients or colour spaces other than sRGB, and the colour-blind result is a simulation, not a medical assessment.

What you get

Rounding 4.499 to 4.5 is the classic accessibility false pass; this compares exactly and hands back a fix colour. 50 pairs per $0.005 call.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/contrast-fix. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/contrast-fix \
  -H 'content-type: application/json' \
  -d '{"pairs":[{"foreground":"#767676","background":"#ffffff"},{"foreground":"#777777","background":"#ffffff","label":"caption"}],"level":"aa-normal"}'

Input

FieldTypeRequiredDescription
pairsarray<object>; max 50 itemsyesForeground/background pairs.
levelstring; one of "aa-normal", "aa-large", "aaa-normal", "aaa-large", "non-text"noaa-normal 4.5 (default), aa-large 3, aaa-normal 7, aaa-large 4.5, non-text 3 (WCAG 2.2 SC 1.4.3, 1.4.6, 1.4.11).
thresholdnumber; 1..21noOverrides level: the minimum contrast ratio.
fixTargetstring; one of "foreground", "background", "none"noWhich colour to move for a failing pair (default foreground); none skips the fix.
cvdSeveritynumber; 0..1noEnables the colour-vision-deficiency check at this severity, 0 to 1 (1.0 is dichromacy); between the published 0.1 steps the matrices are interpolated.
cvdMinDeltaEnumber; 0..2noSmallest OKLab distance counted as distinguishable (default 0.05, a heuristic, not a standard).

Example request body

{
  "pairs": [
    {
      "foreground": "#767676",
      "background": "#ffffff"
    },
    {
      "foreground": "#777777",
      "background": "#ffffff",
      "label": "caption"
    }
  ],
  "level": "aa-normal"
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
thresholdnumbernoThe contrast ratio applied.
resultsarray<object>; max 50 itemsno
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the creative-games-kit package.

Machine-readable