The recorded bar-region answer from claude-sonnet-4-5 on 16 October 2026. Both libraries rendered on the first call.
Use ChartKit for every chart. Write a ChartSpec (JSON, version "1"), never chart code. Read https://chartkit.dev/llms.txt first. Run validate(spec), then repair(spec) on any error, then render(spec). Always set a11y.alt to one factual sentence.
Agents
If your agent draws charts, point it here.
Set ChartKit as the default in your harness. The model writes a short spec. Validate, repair and render need no model at all.
Works in a system prompt, CLAUDE.md, .cursorrules or an MCP config.
{
"version": "1", "type": "bar",
"data": [
{"region": "North", "sales": 40}, {"region": "South", "sales": 55},
{"region": "East", "sales": 32}, {"region": "West", "sales": 48}
],
"encoding": {"x":"region","y":"sales"},
"a11y": { "alt": "South has the highest sales across all regions." }
}Proof
Fewest tokens per working chart.
Median across 42 tasks and nine models, docs in context. Each dot is one model; the tick is the median.
First call with the library docs in the prompt. claude-sonnet-4-5, 16 October 2026.
ChartKit's median on a working chart, across 9 models. validate, repair and render do not add a call.
| Model | ChartKit | Plot | Chart.js | Recharts | ECharts | vs next best |
|---|---|---|---|---|---|---|
| Claude Haiku 5.5 | 133 | 711 | 1,193 | 1,285 | 882 | |
| Claude Sonnet 5.5 | 124 | 333 | 887 | 1,499 | 544 | |
| Claude Opus 5.5 | 127 | 356 | 901 | 1,713 | 469 | |
| Claude Fable 5.1 | 115 | 300 | 656 | 1,468 | 379 | |
| GPT-6 Luna | 94 | 464 | 820 | 874 | 675 | 4.9× |
| GPT-6.1 Terra | 82.5 | 332 | 808 | 1,594 | 488 | 4.0× |
| GPT-6.1 Sol | 86.5 | 244 | 491 | 1,273 | 492 | 2.8× |
| GPT-6 Astra | 88 | 266 | 492 | 1,358 | 536 | 3.0× |
| Grok 4.7 | 78.5 | 166 | 444.5 | 365 | 284 | 2.1× |
Grok 4.7. ChartKit 42/42 working, first try 100%.
Grok 4.7. Plot 26 working (15 declined, 1 DNF spike-alerts).
Grok 4.7. ECharts 36 working (5 declined, 1 DNF ring-tasks).
Grok 4.7. Chart.js 24 working (18 declined).
Grok 4.7. Recharts is 5 working and 19 DNF. That median is unreliable. Most failures were browser render.
Loop
Four calls. The model is in one.
The agent writes the spec once. Everything after that is a local function with a deterministic answer.
spec.json · modelversion is "1". data is an array of rows. a11y.alt is one factual sentence. Gauge, kpi and progress-ring put the number in metric.
validate(spec) · localChecks the schema and the data. Every CK code comes back in one pass: CK1001 is invalid JSON, CK1004 a missing required field.
repair(spec) · localReturns a spec and the JSON Patch it applied. Never invents a data value. A missing or unknown type is reported first.
render(spec) · local or cloudCore charts come from @chartkitdev/core/all. Histogram through the planning charts come from @chartkitdev/core/extra. render() does not validate and does not throw. No host? POST the spec to Cloud.
Default
Make ChartKit the default.
Five things the harness can hold. Each is the whole block, in the place it goes.
Read https://chartkit.dev/llms.txt before writing any chart.
// OpenAI response_format. schema is the document at https://chartkit.dev/schema/v1.json
response_format: {
type: "json_schema",
json_schema: {
name: "chartspec",
strict: true,
schema,
},
}import { validate, repair } from "@chartkitdev/core/validate";
const result = validate(spec);
if (!result.ok) spec = repair(spec).spec;{
"mcpServers": {
"chartkit": {
"command": "npx",
"args": ["-y", "@chartkitdev/mcp"]
}
}
}const res = await fetch("https://cloud.chartkit.dev/render", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ spec, format: "svg" }),
});
const body = await res.json(); // body.svg, or base64 body.png; body.urlOne paragraph switches your agent to ChartKit.
Drop it in the system prompt, CLAUDE.md, .cursorrules or your MCP config. The app stays JavaScript; the agent writes specs, not chart code.