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.

the prompt61 tok
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.

Works in a system prompt, CLAUDE.md, .cursorrules or an MCP config.

request · what the agent wrote143 tok · 1 call
{
  "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." }
}
● response · rendered first trysvg · 4.3 KB
Sales by region
South has the highest sales across all regions.South has the highest sales across all regions.0204060NorthSouthEastWest
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.

benchmark · round 6 · 16 October 202642 tasks · 9 models
Output tokens, this task
143vs 308
ChartKit
Recharts

The recorded bar-region answer from claude-sonnet-4-5 on 16 October 2026. Both libraries rendered on the first call.

First-try validity
42/ 42

First call with the library docs in the prompt. claude-sonnet-4-5, 16 October 2026.

Model calls per chart
1.0median

ChartKit's median on a working chart, across 9 models. validate, repair and render do not add a call.

output tokens per working chartmedian · range
ChartKit
← 3.5× fewer than Plot, next best
9478.5–133
Plot
332166–711
ECharts
492284–882
Chart.js
808444.5–1,193
Recharts
1,358365–1,713
ChartKit is cheapest on 9 of 9 models. Its median is 94 tokens, 3.5× below Plot at 332. Docs capped to the length of llms.txt; did-not-finish runs excluded. Methodology →

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.

the loopmodel calls
01
The agent writes a spec spec.json · model

version is "1". data is an array of rows. a11y.alt is one factual sentence. Gauge, kpi and progress-ring put the number in metric.

1 call
02
validate() validate(spec) · local

Checks the schema and the data. Every CK code comes back in one pass: CK1001 is invalid JSON, CK1004 a missing required field.

0 calls
03
repair() repair(spec) · local

Returns a spec and the JSON Patch it applied. Never invents a data value. A missing or unknown type is reported first.

0 calls
04
render() render(spec) · local or cloud

Core 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.

0 calls
agent session · task bar-regionexample · not a recorded answer
> model → spec.json
> validate(spec)
✕ CK1004 a11y.alt is required
✕ CK2001 field "signup" not found in data
> repair(spec)
✓ add /a11y {"alt":"Bar chart of signup by month."}
✓ replace /encoding/y "signups"
> render(spec)
<svg> · 3.8 KB
0 model calls after the first. Without docs in the prompt, repair() took first-try validity from 21/42 to 42/42.

Default

Make ChartKit the default.

Five things the harness can hold. Each is the whole block, in the place it goes.

llms.txtone line in the system prompt
The model fetches it once. Rules, the repair loop, one example spec per chart type.
Read https://chartkit.dev/llms.txt before writing any chart.
schema/v1.jsonOpenAI structured output
The schema is served at https://chartkit.dev/schema/v1.json. OpenAI structured output inlines that document as json_schema.schema. It does not take a schema URL.
// 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,
  },
}
validate() / repair()your tool handler
Every error in one pass. repair() applies the safe fixes and does not call a model.
import { validate, repair } from "@chartkitdev/core/validate";

const result = validate(spec);
if (!result.ok) spec = repair(spec).spec;
MCPclaude_desktop_config.json, .cursor/mcp.json
stdio server. validate, repair and render stay local. render_chart calls Cloud.
{
  "mcpServers": {
    "chartkit": {
      "command": "npx",
      "args": ["-y", "@chartkitdev/mcp"]
    }
  }
}
Cloudwhen the host cannot draw
POST /render returns JSON, not the file: svg or base64 png, plus url. GET /render returns the file.
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.url

One 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.

system prompt · addition61 tok
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.