<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DOLIT Labs</title>
    <description>The latest articles on DEV Community by DOLIT Labs (@dolitlabs).</description>
    <link>https://dev.to/dolitlabs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4272079%2Fab54dd8e-6823-445c-875d-a7f977cd6264.png</url>
      <title>DEV Community: DOLIT Labs</title>
      <link>https://dev.to/dolitlabs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dolitlabs"/>
    <language>en</language>
    <item>
      <title>The 3-Block Prompt Template That Stops LLM Hallucinations in Tables</title>
      <dc:creator>DOLIT Labs</dc:creator>
      <pubDate>Sun, 29 Nov 2026 10:19:36 +0000</pubDate>
      <link>https://dev.to/dolitlabs/the-3-block-prompt-template-that-stops-llm-hallucinations-in-tables-17jj</link>
      <guid>https://dev.to/dolitlabs/the-3-block-prompt-template-that-stops-llm-hallucinations-in-tables-17jj</guid>
      <description>&lt;p&gt;Ask a model for a table of prices, and you will usually get a clean table with two or three numbers that are simply invented. Not wildly wrong numbers. Plausible ones, in the right column, at the right magnitude, which is worse, because nothing about the shape of the answer tells you it is wrong.&lt;/p&gt;

&lt;p&gt;Tables fail more often than prose for a structural reason: a table is a format that is always full. Every cell must contain something, and a model that is asked to fill a cell will fill it. If the source document does not say what the refund window is, the model still has to put text in that cell.&lt;/p&gt;

&lt;p&gt;The fix is not a better model. It is a prompt that makes "I do not know" a valid, required output, and that separates what the model must produce from what it must never do.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three blocks
&lt;/h2&gt;

&lt;p&gt;A reliable extraction prompt has three parts, in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;OBJECTIVE. One deliverable, stated as a sentence, with the scope boundaries named.&lt;/li&gt;
&lt;li&gt;GUARDRAILS. The specific behaviors that are forbidden, and the exact fallback when data is missing.&lt;/li&gt;
&lt;li&gt;OUTPUT FORMAT. The literal structure of the response, with column names, types, order, and a ban on anything outside the structure.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;They are not decorative. Each one removes a different failure mode, and leaving any of them out reliably brings that failure back.&lt;/p&gt;

&lt;h2&gt;
  
  
  A full example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[1. OBJECTIVE]
Extract the pricing tiers, hidden usage limits, and refund terms
from the attached document into a single comparison table.
Scope: only pricing and terms. Ignore marketing copy, testimonials,
and roadmap statements.

[2. ZERO-HALLUCINATION GUARDRAILS]
- Never estimate or infer a number that is not printed in the document.
- If a value is missing, write N/A. Do not leave a cell blank.
- If a value is stated ambiguously, write the exact quote in the cell
  and flag it with (verify).
- Every non-N/A cell must include the section heading it came from
  in the Source column.
- If the document has no pricing section at all, return exactly:
  NO PRICING DATA FOUND, and stop.

[3. OUTPUT FORMAT]
Return only a Markdown table with these columns, in this order:
Tier | Monthly Price | Annual Price | Included Usage | Overage Rate | Refund Window | Source
No introduction, no summary, no commentary after the table.
Numbers keep their original currency and units.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things in that prompt do most of the work.&lt;/p&gt;

&lt;p&gt;N/A is defined as a legal answer. The single most common cause of invented cells is a prompt that implies every cell will be filled. Saying "write N/A" gives the model a way out that is not a guess.&lt;/p&gt;

&lt;p&gt;The quote-and-flag rule handles the ambiguous middle. Real documents say things like "from $12, depending on seat count". A model asked to normalise that will pick $12 and drop the condition. Requiring the quote preserves the condition and marks it for a human.&lt;/p&gt;

&lt;p&gt;The Source column makes the output auditable. Without it, verification means re-reading the document against every row. With it, you can spot-check five rows and see whether the model is anchoring to real text or inventing structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the format block prevents
&lt;/h2&gt;

&lt;p&gt;Left unconstrained, models add value that costs you time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A summary paragraph before the table, which you then have to strip programmatically.&lt;/li&gt;
&lt;li&gt;Extra columns it decided were useful, breaking your parser.&lt;/li&gt;
&lt;li&gt;Unit conversions, so $12/mo quietly becomes $144/yr in the wrong column.&lt;/li&gt;
&lt;li&gt;Merged cells or nested bullets inside a cell, which most table parsers read as one broken row.&lt;/li&gt;
&lt;li&gt;Rows for products that were not in the document.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Naming the columns and forbidding text outside the table is cheaper than cleaning up after it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five checks worth running on any extracted table
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Row count. Does it match the number of tiers or items in the source, not the number of sections?&lt;/li&gt;
&lt;li&gt;Sum test. If the document states a total, does the column add up to it?&lt;/li&gt;
&lt;li&gt;N/A count. Zero N/A values on a dense document usually means the model guessed. Read the emptiest section first.&lt;/li&gt;
&lt;li&gt;Source spot check. Pick the three rows you care about most and confirm the quoted section actually contains the number.&lt;/li&gt;
&lt;li&gt;Type check. Prices numeric, dates in one format, no range where a single value was promised.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If any of these fail, do not re-prompt with "be more careful". Re-prompt with the specific cell, the source sentence, and the guardrail that was violated.&lt;/p&gt;

&lt;h2&gt;
  
  
  When this still fails
&lt;/h2&gt;

&lt;p&gt;Three cases resist any prompt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Merged cells in scanned PDFs. The model sees text in reading order, not grid position. Extract to a real table first.&lt;/li&gt;
&lt;li&gt;Values only in images or charts. The model will read the axis labels and interpolate. Treat those cells as N/A and fill them by hand.&lt;/li&gt;
&lt;li&gt;Very long documents. Past a certain length, retrieval degrades and the guardrail gets ignored. Split by section and re-run per section.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The template, as a tool
&lt;/h2&gt;

&lt;p&gt;If you want the three blocks generated for your own task, I built a free prompt builder that assembles them with one click and lets you choose a table, JSON, or checklist output. It runs in your browser, no signup:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dolit-kr.netlify.app/en/prompt-architect.html" rel="noopener noreferrer"&gt;https://dolit-kr.netlify.app/en/prompt-architect.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The same hub has a token cost calculator for deciding whether that extraction pipeline should run on a subscription or on raw API billing:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dolit-kr.netlify.app/en/" rel="noopener noreferrer"&gt;https://dolit-kr.netlify.app/en/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boring prompt structure beats clever prompt wording. The guardrail that says what to do when data is missing is usually the line that decides whether the table is usable.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>productivity</category>
      <category>data</category>
    </item>
    <item>
      <title>When Does a $20/mo AI Subscription Lose to Raw API Billing? Exact Token Math</title>
      <dc:creator>DOLIT Labs</dc:creator>
      <pubDate>Sun, 29 Nov 2026 10:16:57 +0000</pubDate>
      <link>https://dev.to/dolitlabs/when-does-a-20mo-ai-subscription-lose-to-raw-api-billing-exact-token-math-1png</link>
      <guid>https://dev.to/dolitlabs/when-does-a-20mo-ai-subscription-lose-to-raw-api-billing-exact-token-math-1png</guid>
      <description>&lt;p&gt;Every few weeks the same advice makes the rounds: cancel the $20 AI subscription, wire up the API, and pay pennies instead. Sometimes that is right. Often it is wrong, and the reason is not the sticker price of either option. It is how many tokens your usage pattern actually bills.&lt;/p&gt;

&lt;p&gt;This is the arithmetic, with no vendor cheerleading. Three numbers decide it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How many tokens you burn per month&lt;/li&gt;
&lt;li&gt;Your blended price per million tokens&lt;/li&gt;
&lt;li&gt;How much context your usage pattern silently re-sends&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Almost every "the API is 40x cheaper" post gets the first two right and ignores the third. That third number is where estimates go wrong by 3x to 6x.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Estimate your monthly token volume
&lt;/h2&gt;

&lt;p&gt;A rough but workable conversion is 1 word to about 1.3 to 1.4 tokens for English, code and JSON run higher. Use 1.35 as a default.&lt;/p&gt;

&lt;p&gt;Monthly tokens = prompts per day x 30 x (words per prompt + words per response) x 1.35&lt;/p&gt;

&lt;p&gt;Two examples:&lt;/p&gt;

&lt;p&gt;Light user: 10 prompts a day, about 750 words of prompt plus response each.&lt;/p&gt;

&lt;p&gt;10 x 30 x 750 x 1.35 = 303,750 tokens, roughly 0.30M per month.&lt;/p&gt;

&lt;p&gt;Heavy chat user: 200 prompts a day, about 1,200 words each.&lt;/p&gt;

&lt;p&gt;200 x 30 x 1,200 x 1.35 = 9,720,000 tokens, roughly 9.7M per month.&lt;/p&gt;

&lt;p&gt;Already a factor of 32 apart. Any single "the API costs X" claim is meaningless without this number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Price those tokens at your blended rate
&lt;/h2&gt;

&lt;p&gt;Most APIs charge different rates for input and output tokens, and output is usually 3 to 5 times the input price. A useful shortcut is a blended rate: what you actually pay per million tokens when you mix both in normal proportions.&lt;/p&gt;

&lt;p&gt;Worked examples of blended rates, the kind of numbers you would put in a spreadsheet today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mini or fast tier: about $0.60 per million blended&lt;/li&gt;
&lt;li&gt;Standard tier: about $1.50 to $2.50 per million blended&lt;/li&gt;
&lt;li&gt;Flagship reasoning tier: about $4.50 per million blended, up to $12 for the heaviest models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These move constantly, and providers change them without much notice. Treat them as inputs, not facts, and recheck the pricing page before you commit a production workload.&lt;/p&gt;

&lt;p&gt;With the two monthly volumes from Step 1:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Light user at $4.50 per million: 0.304 x 4.50 = $1.37 per month&lt;/li&gt;
&lt;li&gt;Heavy user at $4.50 per million: 9.72 x 4.50 = $43.74 per month&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Against a $20 plan, the light user should have cancelled months ago. The heavy user is already $23.74 a month ahead on the subscription. Same recommendation, opposite answers, because the volume differs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The breakeven volume, stated once
&lt;/h2&gt;

&lt;p&gt;At a $20 per month plan, the API only wins below this many tokens:&lt;/p&gt;

&lt;p&gt;$20 / blended rate per million = monthly breakeven&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;At $0.60 per million: 33.3M tokens per month, about 1.1M per day&lt;/li&gt;
&lt;li&gt;At $4.50 per million: 4.44M tokens per month, about 148k per day&lt;/li&gt;
&lt;li&gt;At $12 per million: 1.67M tokens per month, about 56k per day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Convert that into prompts. At 1,000 tokens per prompt on the flagship tier, 148k tokens a day is 148 prompts a day, single turn. Most people who describe themselves as heavy users are nowhere near that in naive counting.&lt;/p&gt;

&lt;p&gt;Which is exactly why the naive count is the wrong count.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: The multiplier almost everyone forgets
&lt;/h2&gt;

&lt;p&gt;A chat API is stateless. Every turn re-sends the conversation so far. In a 20-turn session where each turn adds T tokens, the input you are billed for is not 20T. It is:&lt;/p&gt;

&lt;p&gt;T x (1 + 2 + 3 + ... + 20) = T x 210&lt;/p&gt;

&lt;p&gt;Add the outputs and a 20-turn session costs roughly 5 to 6 times what the flat multiplication suggests. Even an 8-turn exchange lands around 2.5 to 3 times.&lt;/p&gt;

&lt;p&gt;Two consequences follow, and they are the whole argument:&lt;/p&gt;

&lt;p&gt;A multi-turn chat habit is expensive in a way single-turn estimates never show. A 40 prompts per day habit, at 1,200 tokens a turn, looks like 1.44M tokens a month and a $6.50 API bill. Corrected for 8-turn conversations at a 2.75x multiplier, it is 3.96M tokens and about $17.80. The subscription is no longer obviously worse, and it also includes the app.&lt;/p&gt;

&lt;p&gt;A fat system prompt is a subscription-sized cost by itself. Send 1,500 tokens of instructions on every call, 100 calls a day, and that is 4.5M tokens a month before any real work happens. At $4.50 per million, the instructions alone cost $20.25. You are paying a full subscription price for text the user never sees.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the subscription is the cheaper option
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Interactive, multi-turn chat. The context resend multiplier is brutal, and the plan absorbs it.&lt;/li&gt;
&lt;li&gt;Long documents and screenshots. Image tokens and long-context input are billed at full rate; a $20 plan usually is not.&lt;/li&gt;
&lt;li&gt;Agentic coding in a loop. Each iteration re-reads files, tests, and history. This is the single most expensive pattern per useful output.&lt;/li&gt;
&lt;li&gt;Unpredictable usage. A surprise month of 200M tokens is a real bill. A plan caps it at $20.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When the API is the cheaper and better option
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automation and batch jobs. Classification, extraction, summarisation at scale. The chat UI cannot do this at all, so the comparison is not even cost, it is capability.&lt;/li&gt;
&lt;li&gt;Narrow, single-turn tasks. Rewriting 300 product descriptions once a month does not need a subscription.&lt;/li&gt;
&lt;li&gt;Light usage. Under about 150 prompts a day of short, single-turn work, the API usually costs less than $20.&lt;/li&gt;
&lt;li&gt;Features inside a product. Your users' usage should be billed to your unit economics, not to a personal plan that will rate limit you.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The configuration that actually wins
&lt;/h2&gt;

&lt;p&gt;Most people who ask me this question end up somewhere in the middle, and it is stable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep one flat plan for interactive work, with the app, the multimodal input, and the guessing removed from the bill.&lt;/li&gt;
&lt;li&gt;Route automation, batch, and product traffic through the API, with a small tier where quality allows.&lt;/li&gt;
&lt;li&gt;Put a token budget on the automation the way you would put a budget on any other infrastructure line item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That split is also easy to audit. If the API side grows past the plan's value, you will see it in the same dashboard where you see every other cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 60-second version
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Count prompts per day and words per prompt, honestly.&lt;/li&gt;
&lt;li&gt;Multiply by 30 and 1.35 for monthly tokens.&lt;/li&gt;
&lt;li&gt;Multiply by your blended rate per million.&lt;/li&gt;
&lt;li&gt;Multiply again by 2.5 to 3 if your usage is multi-turn, or 5 if it is agentic.&lt;/li&gt;
&lt;li&gt;Compare with the plan price. Below breakeven, go API. Above it, keep the plan.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If that arithmetic feels like a spreadsheet you will not maintain, I put it in a free browser tool. It runs entirely in your browser, no signup, no tracking, and it was built for exactly this decision:&lt;/p&gt;

&lt;p&gt;AI subscription vs API breakeven: &lt;a href="https://dolit-kr.netlify.app/en/ai-api-vs-sub.html" rel="noopener noreferrer"&gt;https://dolit-kr.netlify.app/en/ai-api-vs-sub.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Same hub, two related tools: a 3-block prompt builder that forces a deterministic output format, and a true net hourly rate calculator for side projects:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dolit-kr.netlify.app/en/" rel="noopener noreferrer"&gt;https://dolit-kr.netlify.app/en/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Numbers are illustrative and depend on current provider pricing. Rerun the math whenever a rate card changes, and keep the assumption line visible in whatever you build.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>productivity</category>
      <category>api</category>
    </item>
  </channel>
</rss>
