WCAG 2.2 contrast check with the minimal OKLCH lightness fix and colour-blind pair check
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
| Field | Type | Required | Description |
|---|---|---|---|
pairs | array<object>; max 50 items | yes | Foreground/background pairs. |
level | string; one of "aa-normal", "aa-large", "aaa-normal", "aaa-large", "non-text" | no | aa-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). |
threshold | number; 1..21 | no | Overrides level: the minimum contrast ratio. |
fixTarget | string; one of "foreground", "background", "none" | no | Which colour to move for a failing pair (default foreground); none skips the fix. |
cvdSeverity | number; 0..1 | no | Enables 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. |
cvdMinDeltaE | number; 0..2 | no | Smallest 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.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: 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. |
threshold | number | no | The contrast ratio applied. |
results | array<object>; max 50 items | no | |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always 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
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent