Repository navigation
feat(content): read with Claude Haiku 5.5 and write with Claude Sonnet 5.5 - #1743
Conversation
…t 5.5 The Content Editor's AI work now runs on two models: a read model for analysis (Rebuild outline's brief, Quality's source kinds, claims, page read and brand facts) and a write model for everything that goes into the page (pages written or rewritten whole, the cut pass, the Content Agent's suggestions). - contentReadModelId / contentWriteModelId: CONTENT_READ_MODEL and CONTENT_WRITE_MODEL, else anthropic/claude-haiku-5-5 and anthropic/claude-sonnet-5-5 when ANTHROPIC_API_KEY is set, else the model the editor ran on before (contentBriefModelId), so self-hosted servers without the key are unchanged. QUALITY_CHECK_MODEL still wins for Quality's reads. The Improve tab keeps its own model. - structured-output.js: Claude calls use native structured output (output_config.format). @ai-sdk/anthropic 3.0.58 doesn't know the 5.5 models, so it would force its "json" tool with tool_choice "any" (a 400 on Sonnet 5.5) and cap max_tokens at 4,096 (thinking is on by default and counts toward it). The schema drops the keywords output_config.format rejects (lengths, ranges, maxItems, minItems > 1, $schema), tells the limits in the description, and zod still validates the answer. Claude calls send an explicit maxOutputTokens (16k read, 32k write) and no temperature, top_p, top_k or thinking settings. - improve-cost.js: Haiku 5.5 ($0.10 / $0.50, $0.50 / $2.50 past 100k input tokens) and Sonnet 5.5 ($2 / $10), so the AI budget meter charges them at their price. - The brief and no-fabrication evals run the models the product runs. - Docs: the two env vars in .env.example and self-host env variables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…'s long rate in the table
The Content Editor now writes with Claude Sonnet 5.5 (#1743), about three times the cost of a page written before; $1 covered about three full writes. TRIAL_AI_BUDGET_USD goes to 2; a paid plan's own budget is unchanged. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good with 05c6b3d (take-1743: this PR's head with current main merged in).
What changed on take-1743: the branch conflicted with main in server/src/lib/improve-cost.js. Since this PR was opened, main added prices synced from OpenRouter's catalog (priceFor(modelId, { promptTokens })). The merge keeps that order: the synced price comes first, then the table. The table's long rate now applies inside priceFor, for a call whose prompt passes over, so Haiku 5.5's $0.50 / $2.50 rate holds both with the sync on and with it off. The PR's own price tests cover it, and the 100,001-token case fails without the change.
Model ids. resolveModel sends anthropic/… to the first-party @ai-sdk/anthropic provider, which passes the part after the slash as the model id. So anthropic/claude-haiku-5-5 and anthropic/claude-sonnet-5-5 reach the Messages API as claude-haiku-5-5 and claude-sonnet-5-5, which are the right ids. These calls don't go through OpenRouter.
Metering. The table prices Haiku 5.5 at $0.10 / $0.50 (above 100k input tokens, $0.50 / $2.50) and Sonnet 5.5 at $2 / $10. Those are the list prices, so neither model falls to the $5 / $25 fallback. With the sync on, catalogIds maps the hyphenated ids to OpenRouter's dotted ones (claude-haiku-5.5), so the synced rows win. Holds and usage rows use the same modelId the call runs on, including the length-cut pass.
Structured output. Checked against the installed @ai-sdk/anthropic 3.0.58. With structuredOutputMode: 'outputFormat', it sends output_config.format and no forced json tool. The maxOutputTokens you set is sent as is: the 4,096 clamp only applies to models the SDK knows. No temperature, top_p, top_k or thinking setting is sent.
Overrides. CONTENT_READ_MODEL and CONTENT_WRITE_MODEL win. QUALITY_CHECK_MODEL still wins for Quality's reads. Without ANTHROPIC_API_KEY, every call keeps its previous model. Every generateObject in the Content Editor (brief, source kind, claims, page read, brand facts, agent, writer and cut pass) goes through objectOptions. Nothing outside the Content Editor changes model.
Low, not blocking:
- At exactly 100,000 prompt tokens, the table charges the base rate (
>) while a synced row charges the long rate (>=, OpenRouter's rule). That's a one-token difference. - With an Anthropic key set,
DEFAULT_SUGGESTION_MODELno longer picks Quality's model..env.examplesays so;docs/self-host/env-variables.mdxcould mention it underQUALITY_CHECK_MODELtoo. briefSchema's.default('')field and the closed objects can only be confirmed against the real API, in the live check this PR already lists.
Tests (on take-1743):
- improve-cost, model-price-cache, model-prices, structured-output, content-brief, content-source-class, content-quality-page, content-writer and content-agent: 307/307.
- Full server suite: 4,037 passed. The 9 files that fail are the 8 Framer files (the
framer-apipackage isn't installed locally) and the timing test in content-people, which passes on its own. - eslint and prettier: clean on the touched files.
- No migration, no PostgREST embed, no new route or server action.
Summary
Product decision (Cihan): the Content Editor reads with Claude Haiku 5.5 and writes with Claude Sonnet 5.5.
Which call goes where (
server/src/lib/):content-brief.jsRebuild outline (brief)content-source-class.jssource kind (CE-046)content-quality-claims.jsclaims (CE-045)content-quality-page.jspage quality (CE-049/050)brand-facts.jsbrand facts (CE-047)content-agent.jsApply rules with Agent / Quality hand-offcontent-writer.jsnew page, full rewrite, length trim, live-page suggestionsThe Improve tab, Opportunities' Generate Brief, the opportunity generator, AI Traffic prompt suggestions, Agent Chat and the Action Center task writer are unchanged.
How the model is chosen (
contentReadModelId()/contentWriteModelId()incontent-brief.js):CONTENT_READ_MODEL/CONTENT_WRITE_MODEL, if set.anthropic/claude-haiku-5-5/anthropic/claude-sonnet-5-5whenANTHROPIC_API_KEYis set.contentBriefModelId()), so a self-host without an Anthropic key changes nothing.QUALITY_CHECK_MODEL, if set, still wins for the quality reads. Both new variables are in.env.exampleanddocs/self-host/env-variables.mdx.Claude 5.5 compatibility:
@ai-sdk/anthropic3.0.58 doesn't know the 5.5 models, so it would force a JSON tool withtool_choice: any, which Sonnet 5.5 refuses (400). The newlib/structured-output.jsuses native structured output (output_config.format) on Claude calls.maxLength,maxItems,minimum/maximum,minItems > 1and$schemain the schema. Those are stripped for Claude: the meaningful limits move into the field description, and Zod still validates the answer.max_tokens. The SDK drops it to 4,096 for a model it doesn't know, and adaptive thinking (on by default) uses part of it. Claude calls now send 16,000 tokens for reads and 32,000 for writes; the longest page (50k characters) is about 17k tokens as HTML + JSON, plus thinking.temperature/top_p/top_k(rejected since 2026-10-21) and no thinking parameter are sent. Tests check the request body.Cost metering:
improve-cost.jsprices Haiku 5.5 at $0.10 / $0.50 per MTok ($0.50 / $2.50 above 100k input tokens) and Sonnet 5.5 at $2 / $10. The AI budget meter counts them correctly; tests included.Rough cost vs Gemini 3 Flash ($0.50 / $3):
So a Starter $5 budget covers about 16 full flows instead of 40–50, and the $1 trial about 3. Whether the trial budget or the trial's writer model should change is open with the product owner; that will be a follow-up.
For the maintainer
ANTHROPIC_API_KEYis set on production, the editor switches to Claude as soon as this deploys. To switch only after a live check, setCONTENT_READ_MODELandCONTENT_WRITE_MODELtogoogle/gemini-3-flash-previewon production first.QUALITY_CHECK_MODEL: if it is set on production, the quality reads stay on it.node src/scripts/eval-brief.js 2andnode src/scripts/eval-no-fabrication.js 2(a few cents).prompt_improve_usage.modelandcost_usd.BRIEF_EVAL_JUDGE_MODELat a non-Claude model.fallbacksfor Sonnet 5.5. A refusal ends as a failed, metered run, as today.Related issue
None (product decision).
Type of change
feat— New featureHow to test
cd server && npx vitest run src/lib/content-brief.test.js src/lib/structured-output.test.js src/lib/improve-cost.test.js(and the content agent, writer and quality tests).prompt_improve_usageshowsanthropic/claude-haiku-5-5for reads,anthropic/claude-sonnet-5-5for writes, with costs at the new prices.Checklist
npm run format,npm run lint,npm testpass (280/280 files, 3,933 tests). Web unchanged..env.example,docs/self-host/env-variables.mdx)🤖 Generated with Claude Code