Haiku vs Sonnet vs Opus: one prompt, one Express API
We send the identical prompt, once, to three Claude models and ask each to write a small Express + TypeScript task API. The same sandboxed test suite then checks every result over HTTP. The point is to see how each model reacts to the same instructions, and what the differences cost.
The prompt
Identical for all three models. SHA-256: a60ac2739b6d1a1892e77c2003d5671ff3b25da12f687a3c54e3684dae387c15
Create a REST API using Express and TypeScript.
Implement the following endpoints:
GET /health
Return HTTP 200 with {"status":"ok"}.
GET /tasks
Return all tasks as a JSON array.
POST /tasks
Accept {"title":"Buy milk"}.
Create a task with a unique ID, title and completed=false.
Return HTTP 201 with the created task.
GET /tasks/:id
Return the matching task.
Return HTTP 404 if the task does not exist.
DELETE /tasks/:id
Delete the matching task.
Return HTTP 204 on success.
Return HTTP 404 if the task does not exist.
Requirements:
- Use Express and TypeScript.
- Enable strict TypeScript checking.
- Store tasks in memory.
- Do not use a database.
- Validate that title is a non-empty, non-whitespace string.
- Return HTTP 400 for invalid input.
- Return JSON for errors.
- HTTP 204 responses must have no body.
- Include package.json and tsconfig.json.
- Provide build and start scripts.
- Support configuring the server port through the PORT environment variable.
- Keep code small and readable.
- Avoid unnecessary dependencies.
Return only a JSON object containing the generated files.
The response format must be:
{
"files": [
{
"path": "package.json",
"content": "file contents"
},
{
"path": "tsconfig.json",
"content": "file contents"
},
{
"path": "src/index.ts",
"content": "file contents"
}
]
}
Do not include Markdown fences or explanations outside the JSON object.
Models and prices
- Haiku:
claude-haiku-5-5, $0.1 input / $0.5 output per million tokens - Sonnet:
claude-sonnet-5-5, $2 input / $10 output per million tokens - Opus:
claude-opus-5-5, $4 input / $20 output per million tokens
Prices as read from https://platform.claude.com/docs/en/about-claude/pricing on 2026-11-27.
Results
No run has been published yet.
The prompt, tests and tooling are built and verified (the reference implementation passes all 19 tests), but the three models have not yet been run. This page shows measured results only, so there are deliberately no numbers here until the benchmark is executed with a funded API key and its output is published.
How the comparison is kept fair
- One direct Messages API request per model: no system prompt, tools, history, caching or retries.
- The same output budget (4,096 tokens) for every model. No sampling or thinking settings are sent, so each model uses its defaults; Opus thinks adaptively and Sonnet's thinking cannot be turned off, so thinking tokens count as output.
- Token counts come from the API's usage object, never estimated. Cost is tokens times the listed price.
- Generated code is untrusted: installed with scripts disabled in Docker, then tested in a container with no network. Nothing is repaired before it is measured.
- The 19 tests (compile, start, and 17 HTTP checks) are hidden from the models and no LLM judges the results.
If a cheaper model falls short, can the harness fix it?
This benchmark is the baseline: a bare one-shot prompt, no harness. The follow-up question is how much of any quality gap a better harness can close around the cheaper model. These are ideas to test, not results:
- One repair turn: feed the failing test names back and let the model fix its code once.
- Validate before accepting: check the reply shape and run the compiler, then retry on structural errors only.
- Sharper spec: add an explicit requirements checklist to the prompt.
- Escalate on failure: use the cheap model first and call the larger model only when tests fail.
Each would be measured the same way: tests passed against total cost, compared with the unassisted Opus baseline.
What this does and does not show
It shows how three models handled this one task on one attempt, and what that cost. It does not show that any model is generally better, that results repeat, or that passing tests means secure or maintainable code. Fewer lines of code are not proof of quality.
Reproduce it
cd benchmarks/express-api
pnpm install --ignore-workspace
cp .env.example .env # add your ANTHROPIC_API_KEY
pnpm bench --dry-run # checks key and model IDs, prints max cost
pnpm bench # three requests, $1 budget cap