<?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: Rustam Kolumbayev</title>
    <description>The latest articles on DEV Community by Rustam Kolumbayev (@rustam_kolumbayev_e97ba1d).</description>
    <link>https://dev.to/rustam_kolumbayev_e97ba1d</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%2F4265440%2F112b761d-e7b8-4211-830f-2a5c9bbe7759.jpg</url>
      <title>DEV Community: Rustam Kolumbayev</title>
      <link>https://dev.to/rustam_kolumbayev_e97ba1d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rustam_kolumbayev_e97ba1d"/>
    <language>en</language>
    <item>
      <title>I Gave Up Law and Worked Night Shifts to Become a Developer. Then AI Fixed My Bug in One Prompt.</title>
      <dc:creator>Rustam Kolumbayev</dc:creator>
      <pubDate>Wed, 25 Nov 2026 21:16:03 +0000</pubDate>
      <link>https://dev.to/rustam_kolumbayev_e97ba1d/i-gave-up-law-and-worked-night-shifts-to-become-a-developer-then-ai-fixed-my-bug-in-one-prompt-4m6p</link>
      <guid>https://dev.to/rustam_kolumbayev_e97ba1d/i-gave-up-law-and-worked-night-shifts-to-become-a-developer-then-ai-fixed-my-bug-in-one-prompt-4m6p</guid>
      <description>&lt;p&gt;I gave Claude Code a bug. Not a cute one. The kind that eats an entire day: reproduce it, dig through logs, trace it across five files, try three wrong fixes before the right one.&lt;/p&gt;

&lt;p&gt;One prompt later, it was fixed.&lt;/p&gt;

&lt;p&gt;I sat there staring at the diff like it had insulted my family. And then a very quiet, very unpleasant thought showed up:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Did I do all of that for nothing?&lt;/em&gt; 😶&lt;/p&gt;

&lt;p&gt;To explain why that thought hurt so much, I have to rewind to a law school, a bank, and a lot of night shifts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxrv1kiniowsqw374hhwo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxrv1kiniowsqw374hhwo.png" alt="Developer staring at a one-prompt bug fix" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Eight hours of plans. Zero needed.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  I was supposed to be a lawyer
&lt;/h2&gt;

&lt;p&gt;In my last year of law school I interned at Citibank. On paper it was legal and compliance work. In practice I kept drifting toward the software side of things: the systems, the tools, the people who built them. I got curious, and the curiosity refused to leave.&lt;/p&gt;

&lt;p&gt;I finished my law degree anyway. I'd come that far. Then, in 2019, I moved to the US for a job that had nothing to do with tech, and the question came with me in my suitcase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Day shift, night shift
&lt;/h2&gt;

&lt;p&gt;I took CS50 online and later joined a coding bootcamp. Good friends gave me my first real chance: a role at their small startup, building React and React Native features and learning by shipping to actual users.&lt;/p&gt;

&lt;p&gt;It did not pay the bills. So my schedule looked like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Daytime:&lt;/strong&gt; writing code at the startup&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nighttime:&lt;/strong&gt; a warehouse shift, and later a night shift at Ross&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Somewhere in between:&lt;/strong&gt; sleep, in theory 🙃&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7d3okjlbtijdtnvn2j84.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7d3okjlbtijdtnvn2j84.png" alt="Same developer at 9 AM coding and at 11 PM carrying boxes in a warehouse" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Two jobs, one hoodie.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The hardest part wasn't the code. It was believing it would eventually turn into a "real" developer job, when everything about my résumé said "lawyer who stocks shelves."&lt;/p&gt;

&lt;h2&gt;
  
  
  The night shift ends
&lt;/h2&gt;

&lt;p&gt;In 2021 I got my first full-time engineering role at a consultancy, building React and Node apps for big enterprise clients. I quit the night shifts. 💃&lt;/p&gt;

&lt;p&gt;Within a year I was leading a small UI team and running incident response for a global retailer's inventory system. A few years earlier I'd been reading contracts.&lt;/p&gt;

&lt;p&gt;From there: a privacy-focused ML startup, where I was the only frontend engineer. Then the senior role I have now, where most of my work is AI: LLM integrations, evaluation, and keeping model costs from exploding.&lt;/p&gt;

&lt;p&gt;I'd made it. Which, as you already know from the first paragraph, is exactly when the universe sent a bug fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  The very bad thought
&lt;/h2&gt;

&lt;p&gt;Back to that diff.&lt;/p&gt;

&lt;p&gt;The law degree I walked away from. The bootcamp. The warehouse. Ross. Learning React at 2 a.m. on almost no sleep. Years of grinding to get into a profession, and just as I got comfortable, a machine was doing in seconds the thing I'd fought so hard to learn.&lt;/p&gt;

&lt;p&gt;I'd already switched careers once. I wasn't sure I had a second switch in me.&lt;/p&gt;

&lt;h2&gt;
  
  
  What pulled me out of it
&lt;/h2&gt;

&lt;p&gt;What helped was remembering something I'd already lived through.&lt;/p&gt;

&lt;p&gt;Before Claude Code existed, I built the UI for a product that was applying to Y Combinator. I used AI to help, and I shipped it in a matter of &lt;em&gt;days&lt;/em&gt;. A few years earlier the same work would have taken me months. The application ranked in the top 10% of Y Combinator applicants.&lt;/p&gt;

&lt;p&gt;AI didn't build that product. I did, faster than I could have alone. I decided what to build, what "good" looked like, and when the AI's output was wrong. Spoiler: it was wrong plenty.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flqjwd95t7i7o79tcb4sw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flqjwd95t7i7o79tcb4sw.png" alt="Developer with a clipboard supervising a row of robot interns" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Very fast. Very confident. Occasionally correct.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So instead of running from AI, I made it my job. The more time I spent with these models, the less scared I got. They're incredibly fast. They're also confidently wrong in ways that are easy to miss if you don't know what you're looking at. They don't know what your users need. They don't notice when "working" code quietly does the wrong thing.&lt;/p&gt;

&lt;p&gt;Someone has to. Turns out that someone is me.&lt;/p&gt;

&lt;p&gt;These days I build open-source tools around AI, like &lt;a href="https://github.com/Rubick1997/twopass" rel="noopener noreferrer"&gt;TwoPass&lt;/a&gt;, which double-checks cheap batch LLM output so you don't pay for the expensive model on every call. My whole approach fits in one line: an agent on autopilot is a liability; an agent supervised by someone who understands the code is a superpower.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, was it all for nothing?
&lt;/h2&gt;

&lt;p&gt;No. Everything I learned the hard way is exactly what lets me use AI well instead of being replaced by it. I can read the code it writes and know when it's wrong. I know what "done" means, because I've been on incident duty when it wasn't.&lt;/p&gt;

&lt;p&gt;Even law school, the thing I thought I'd wasted, turned out to matter. Lawyers are trained to read carefully, question every assumption, and hunt for the one clause that breaks the argument. That is precisely what reviewing AI-generated code demands. 🧐&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo1nkfusjl0mk1opgozpy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo1nkfusjl0mk1opgozpy.png" alt="Developer in a lawyer robe reading code with a magnifying glass" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Turns out code review is just contract law with semicolons.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The job didn't disappear. It changed shape: less typing, more judging. And judgment is the part you can't skip your way into.&lt;/p&gt;

&lt;p&gt;Could someone make my switch today? I think yes, but differently. The beginner tasks I learned on are the ones AI handles best now, so the first rung feels harder to reach. But today's career changer also has a tutor that never sleeps and never gets tired of "why?" Use it to &lt;em&gt;understand&lt;/em&gt;, not to skip understanding, and you'll learn faster than I ever could.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you're where I was
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Your "irrelevant" background isn't irrelevant.&lt;/strong&gt; Find the part that transfers. Mine was careful reading and skepticism.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ship real things early,&lt;/strong&gt; even unpaid, even small. The startup work mattered more than any certificate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use AI as a teacher, not a ghostwriter.&lt;/strong&gt; Ask it to explain, write it yourself, then ask it to review you.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Do I regret not becoming a lawyer?
&lt;/h2&gt;

&lt;p&gt;Honestly? It's a hard question. Sometimes I do.&lt;/p&gt;

&lt;p&gt;But mostly I don't. The market feels rough right now, and every day there's news of another round of layoffs. Even so, tech still feels full of possibility to me. There's still room to be creative, to build something out of nothing and put it in front of people.&lt;/p&gt;

&lt;p&gt;And the scariest thing I've learned is also the most comforting: the night shift ends. Even the one AI put me on. 🌅&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5bl30j195lj19rs4amr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5bl30j195lj19rs4amr.png" alt="Developer walking out of a warehouse at sunrise with a laptop" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Clocking out. For good.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you're switching careers into code right now, or wondering if AI just made your hard work pointless, I'd love to hear where you're at in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>codenewbiestory</category>
      <category>career</category>
      <category>ai</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Treat LLM Output as a Build Artifact: Batch APIs and Jev</title>
      <dc:creator>Rustam Kolumbayev</dc:creator>
      <pubDate>Wed, 25 Nov 2026 20:50:35 +0000</pubDate>
      <link>https://dev.to/rustam_kolumbayev_e97ba1d/treat-llm-output-as-a-build-artifact-batch-apis-and-jev-4b3b</link>
      <guid>https://dev.to/rustam_kolumbayev_e97ba1d/treat-llm-output-as-a-build-artifact-batch-apis-and-jev-4b3b</guid>
      <description>&lt;p&gt;&lt;em&gt;How precomputing every answer turned a 31-second request into a 2 KB static file, with a frontier model writing and Jev checking its work.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A model call per request is the wrong default
&lt;/h2&gt;

&lt;p&gt;The first version of the demo took 31 seconds to answer a single click.&lt;/p&gt;

&lt;p&gt;It was a personalization demo. A visitor picks any of 12 interests and gets a short paragraph describing people who share them. Behind each click, the server made 11 data calls and 7 model calls while the visitor watched a spinner. A cache wouldn't have saved it either, because a cache only helps the second person to pick the same selection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frirdxjn0hooablzsd5ai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frirdxjn0hooablzsd5ai.png" alt="A bearded man waits at a laptop showing a loading spinner while a clock reads 0:31" width="799" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Somewhere around call 14, the visitor grew a beard.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then I did the arithmetic. Twelve interests give 2¹² − 1 = 4,095 possible selections. That's few enough to write every answer before anyone asks.&lt;/p&gt;

&lt;p&gt;That turns the model's output into a build artifact. A build step generates and checks every paragraph offline and writes each one to a static file. The model runs once, at build time, the way a compiler does.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnntvqr6d4o2lqlxa8twz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnntvqr6d4o2lqlxa8twz.png" alt="Diagram: before, the model runs on every request and takes 31 seconds; after, the model runs once at build time and a CDN serves a 2 KB file" width="799" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The examples below use a made-up online shop instead of the original project. It has 12 filters such as "waterproof" and "vegan materials", which gives 4,095 filter combinations, and each combination gets a short "who buys this" paragraph grounded in the shop's own product attributes and reviews.&lt;/p&gt;

&lt;p&gt;The approach rests on two ideas: precompute the whole space, and split the work between two models. A frontier model writes, and Jev checks what it wrote. Jev (&lt;code&gt;typesafe/jev-1.13&lt;/code&gt;) is a small decision model from TypeSafe, available through OpenRouter. It returns typed answers with confidences instead of free text. The writer's calls go through a batch API at half price, behind a small queue that keeps the code as simple as a normal &lt;code&gt;await&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Precompute the whole space
&lt;/h2&gt;

&lt;p&gt;The page never talks to a model. It fetches a file that the build step wrote earlier, one per combination.&lt;/p&gt;

&lt;p&gt;Each selection is encoded as a bit field, where filter &lt;em&gt;n&lt;/em&gt; sets bit &lt;em&gt;n&lt;/em&gt;. The result is a number from 1 to 4,095 that also names the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;selected&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="sb"&gt;`/api/writeup/${mask}.json`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A file is about 2 KB and a CDN serves it in milliseconds. Nothing in the request path needs an API key or can hit a rate limit, and the bill doesn't grow with traffic.&lt;/p&gt;

&lt;p&gt;Building ahead of time has a second benefit: every output can be checked before a visitor sees it. You can't do that when the model writes at request time. The cost is paid once, during the build.&lt;/p&gt;

&lt;p&gt;This only works while the space stays countable. Twelve inputs give 4,095 combinations, while twenty would give more than a million. Past some size, one full pass stops being affordable.&lt;/p&gt;

&lt;p&gt;To ship before the run finishes, sort the work queue by how close each combination is to the default selection. The combinations a visitor reaches in one or two clicks are done first and can be published while the rest of the run continues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Every sentence traces to evidence
&lt;/h2&gt;

&lt;p&gt;With the model out of the request path, there is time to check its work. The pipeline uses that time so that every sentence a shopper reads can be traced back to data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhfyo78qt5qte0c7wynin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhfyo78qt5qte0c7wynin.png" alt="Diagram of the checking pipeline from evidence to shipped file" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each combination goes through nine steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Evidence. Pull structured signals from the shop's data, both for the whole combination and for each filter on its own. Each signal is credited to the filters that drive it and gets a row number such as E7.&lt;/li&gt;
&lt;li&gt;Claims. The writer proposes 4 claims that cite evidence rows by id. Each must stay under 20 words and avoid explanatory clauses.&lt;/li&gt;
&lt;li&gt;Rule checks. Plain code drops any claim that cites a row that doesn't exist or names a forbidden term.&lt;/li&gt;
&lt;li&gt;Fact-check. Jev gets one request per combination with one question per claim, and labels each claim supported, overstated or unsupported. A claim survives only as "supported" with a confidence of at least 0.6. Because Jev can't rewrite anything, a weak claim is dropped.&lt;/li&gt;
&lt;li&gt;Repair. When a filter has no surviving claim, the writer proposes one claim for it, and that claim goes through steps 3 and 4.&lt;/li&gt;
&lt;li&gt;Paragraph. The writer turns the kept claims into 3 to 4 sentences and tags each claim's phrase.&lt;/li&gt;
&lt;li&gt;Faithfulness. Jev estimates the probability that the paragraph adds a fact none of the claims contain. At 0.5 or higher the writer rewrites the paragraph, up to 3 times.&lt;/li&gt;
&lt;li&gt;Retry. If too few claims survive, the model steps run again with fresh answers, up to 6 attempts per combination.&lt;/li&gt;
&lt;li&gt;Ship. The build writes one JSON file per combination.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A claim stays short and plain so that it can be checked against its rows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"C1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Shop for wet daily commutes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"evidence"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"E3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"E7"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the paragraph, a tag marks the phrase that came from each claim.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;These shoppers &lt;span class="nt"&gt;&amp;lt;b&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"C1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;walk to
work in the rain&lt;span class="nt"&gt;&amp;lt;/b&amp;gt;&lt;/span&gt; and ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The page uses that tag to show the evidence behind each phrase, so hovering over "walk to work in the rain" shows rows E3 and E7. A reader can check the paragraph without having to trust it.&lt;/p&gt;

&lt;p&gt;This is a real claim from the project: "In restaurants and venues, they gravitate toward cozy, romantic, intimate settings." Its evidence rows are below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"C1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"evidence"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Cozy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Places"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"score"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.98&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Romantic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Places"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"score"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.96&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Intimate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Places"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"score"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.89&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Splitting the work this way keeps each check narrow. A claim is judged on its own against the rows it names, and the paragraph is judged only on whether it adds anything, so a small model like Jev can handle both questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  A frontier model writes, Jev checks
&lt;/h2&gt;

&lt;p&gt;To cut costs, I first used a smaller model as the writer. It kept adding explanations nobody asked for, such as "favoring calm, considered design over clutter", and Jev correctly called them overstated. Only 25% of its claims survived.&lt;/p&gt;

&lt;p&gt;That failure led to the rule limiting claims to 20 words without explanatory clauses, which raised survival to 52%. The paragraphs built from the survivors still read badly, though, with invented details and stilted boilerplate that the checks flagged but couldn't fix.&lt;/p&gt;

&lt;p&gt;So I went back to a frontier model, Claude Opus, for the writing. Writing is open-ended, and its quality shows in every sentence. Judging is a closed question about one claim and the few rows behind it, and a small model handles that well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk6piuetzruw9ajyzt99k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fk6piuetzruw9ajyzt99k.png" alt="A big blue robot in a beret labeled Opus holds up a page while a tiny green robot labeled Jev inspects a circled line with a magnifying glass; price tags read Writes: $120 and Checks: $0.42" width="799" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The writer gets the budget. The checker gets the red pen.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Jev doesn't take a free-form prompt. It takes a &lt;code&gt;state&lt;/code&gt; object plus named questions and returns a typed answer for each. A &lt;code&gt;choice&lt;/code&gt; question returns an option with a confidence, and a &lt;code&gt;noul&lt;/code&gt; question returns the probability of yes.&lt;/p&gt;

&lt;p&gt;The criteria are plain text, defined once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;criteria&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;supported&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s1"&gt;'Every quality the claim names comes '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="s1"&gt;'from its evidence, in plain words. '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="s1"&gt;'Naming two signals together is supported.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;overstated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s1"&gt;'Adds something no evidence names: a '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="s1"&gt;'detail, an absolute degree, a motive, '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="s1"&gt;'or one new kind of item that merges '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="s1"&gt;'separate signals.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;unsupported&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s1"&gt;'The evidence does not point this way.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One request then checks every claim in a combination.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;claim&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;evidence&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;questions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromEntries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sb"&gt;`c${i}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'choice'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;instructions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`Judge items[${i}].claim `&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
      &lt;span class="sb"&gt;`against only items[${i}].evidence.`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;criteria&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;answers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'https://openrouter.ai/api/alpha/decisions'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'typesafe/jev-1.13'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;questions&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the answers come back typed, keeping a claim is a plain filter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;kept&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;answers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sb"&gt;`c${i}`&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'supported'&lt;/span&gt;
    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Faithfulness uses a single &lt;code&gt;noul&lt;/code&gt; question named &lt;code&gt;added&lt;/code&gt;, and the writer rewrites the paragraph when its probability is 0.5 or higher. I set that threshold low because a rewrite costs little and padding that reaches a reader costs more.&lt;/p&gt;

&lt;p&gt;Across the final run, all of Jev's checks for 4,077 combinations cost $0.42. Not per combination. In total.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Jev before you trust it
&lt;/h2&gt;

&lt;p&gt;Before Jev saw real work, I gave it cases with known answers. It labeled a supported, a deliberately overstated and an unsupported claim correctly, at confidences of 0.89, 1.00 and 0.82. It scored a faithful paragraph 0.18 for added facts and a paragraph with invented facts 0.97, and it agreed with the frontier model on 17 of the 18 claims that model had already approved.&lt;/p&gt;

&lt;p&gt;That's a small smoke test: 3 claims, 2 paragraphs and 18 cross-checked claims. It gave me enough confidence to start the run, and the run itself showed what it missed.&lt;/p&gt;

&lt;p&gt;The last 18 combinations kept failing. In one of them, the claim "drawn to detective work and corruption" rested on two evidence rows naming exactly those signals at maximum strength, and Jev still called it overstated with confidence up to 0.94.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwevk8fli0fx3k41ngke0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwevk8fli0fx3k41ngke0.png" alt="Evidence card shows Detective work 1.00 and Corruption 1.00; a smug green robot stamps OVERSTATED, confidence 0.94 on the matching claim" width="799" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Jev, confidently wrong about a correct claim.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Jev had read the two signals, named together, as one new thing merged from both. My first criteria never said that naming them together was allowed. So I rewrote the criteria: naming signals together is supported, and only merging them into a single new kind of item is overstated. Those are the two sentences you saw in the criteria above.&lt;/p&gt;

&lt;p&gt;With the new wording, the misjudged claims passed at 0.84 to 0.97, while real overstatements still failed at 0.95 to 0.99. At the same time I raised the keep threshold from 0.5 to 0.6. The main run had used 0.5 with the first wording, and the new settings applied to the last 8 combinations.&lt;/p&gt;

&lt;p&gt;Criteria for a decision model deserve the same care as code. I now keep a set of known cases, rerun it after every wording change, and read whatever still fails. When a run stalls on the same few inputs, check the criteria before you blame the writer.&lt;/p&gt;
&lt;h2&gt;
  
  
  Half-price batches you can await
&lt;/h2&gt;

&lt;p&gt;Model providers offer a batch API at about half price, where you upload many requests at once and download the results when the batch finishes. Pipelines written around that shape end up as a submit-and-poll loop that matches results back to requests, which is hard to read and harder to change.&lt;/p&gt;

&lt;p&gt;A small queue avoids that by letting pipeline code call &lt;code&gt;batched(params)&lt;/code&gt; and await it like a normal request. Behind it, calls collect until 20 seconds pass with no new ones or 2,000 are waiting, and then go out as one batch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr1diem2np60gczhmbks3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr1diem2np60gczhmbks3.png" alt="Requests r0 to r6 wait at a Batch Bus Stop whose sign says it departs after 20 s of nobody new or when 2,000 passengers are waiting, all fares half price" width="799" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Half fare, as long as you don't mind waiting for the bus.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;queue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;idle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nextId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;batched&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nf"&gt;enqueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`r${nextId++}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;enqueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;idle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20_000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;idle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;runBatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;runBatch&lt;/code&gt; submits the batch and settles each waiting promise once the batch ends.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;runBatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;batches&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;custom_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;waitUntilEnded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// poll every 30s&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;byId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;batches&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;results&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;byId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;custom_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;byId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;custom_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'succeeded'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;retryOrReject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;byId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'missing'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;retryOrReject&lt;/code&gt; puts a failed or expired request back in the queue up to twice and then rejects it. In real code, wrap the body in a try/catch that rejects every item if the batch itself fails.&lt;/p&gt;

&lt;p&gt;The queue pays off only when many calls are waiting at the same moment, so the build starts all 4,095 combinations at once. Each one runs until its first &lt;code&gt;await&lt;/code&gt;, which puts every claims call into the first round of batches. The 2,000 cap splits that round across a few batches, and after Jev filters the claims, every paragraph call fills the next round. The whole run took 12 batches, and the pipeline code still reads like sequential code.&lt;/p&gt;

&lt;p&gt;The trade-off: batching makes the run take longer without adding any calls, because each combination waits on several batch rounds.&lt;/p&gt;

&lt;h3&gt;
  
  
  A cache keyed on the exact request
&lt;/h3&gt;

&lt;p&gt;A disk cache makes iteration cheap. Every external response is stored under a key built from the exact request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="no"&gt;CACHE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'.json'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'utf8'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="sb"&gt;`llm|${JSON.stringify(params)}|${attempt}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;batched&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because finished calls are cache hits, a stopped run resumes for free. Changing one prompt changes only that step's keys, so only that step and the steps after it run again. A retry passes its attempt number into the key to get a fresh answer instead of the cached one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;The shipped setup cost about $0.03 per combination, a quarter of the first setup.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F643wn43n26pjomgi6faa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F643wn43n26pjomgi6faa.png" alt="Cost figures for the first, cheaper and shipped setups" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first setup used a frontier model for both writing and judging, at full price, and cost about $0.12 per combination, or about $490 projected for all 4,095. The cheaper writer with batching and Jev cost $0.017 to $0.02 per combination, but its paragraphs weren't good enough to ship.&lt;/p&gt;

&lt;p&gt;These are the figures for the final run.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Combinations finished in the main run: 4,077 of 4,095&lt;/li&gt;
&lt;li&gt;Cost: $120.66&lt;/li&gt;
&lt;li&gt;Batches: 12&lt;/li&gt;
&lt;li&gt;Wall time: about 53 minutes&lt;/li&gt;
&lt;li&gt;All Jev checks: $0.42&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last 18 finished later for about $1.20 more, 10 through retries and 8 after the criteria fix, so all 4,095 shipped.&lt;/p&gt;

&lt;p&gt;I didn't measure how much of the roughly 4x saving came from batching and how much from moving the checks to Jev. The writer model was the same in the first and shipped setups, so the difference comes from those two changes alone. Batching halves the price of every model call, and Jev's total bill was $0.42.&lt;/p&gt;

&lt;p&gt;A visitor now downloads one static file of about 2 KB per selection. The first version took 31 seconds per request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where else this works
&lt;/h2&gt;

&lt;p&gt;The pattern fits any feature whose inputs can be listed and whose output can wait for a build. Some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;quiz results for each answer pattern&lt;/li&gt;
&lt;li&gt;onboarding paths for each combination of role and goal&lt;/li&gt;
&lt;li&gt;product copy for each variant&lt;/li&gt;
&lt;li&gt;localized copy for each string and language&lt;/li&gt;
&lt;li&gt;support answers for known issue types&lt;/li&gt;
&lt;li&gt;landing pages for each city or category&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's worth doing when you can list every input and afford one pass over all of them. Then the checking pipeline lets you review every output before it ships, which request-time generation never allows.&lt;/p&gt;

&lt;p&gt;Before you reach for a faster model or a bigger cache, count the inputs. If the number fits in a build, the visitor never has to wait for a model at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Jev
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://openrouter.ai/docs/guides/community/jev" rel="noopener noreferrer"&gt;Jev on OpenRouter&lt;/a&gt;. The developer guide covers the Decisions API endpoint used in this article and the three question types: &lt;code&gt;choice&lt;/code&gt;, &lt;code&gt;noul&lt;/code&gt; and &lt;code&gt;score&lt;/code&gt;. Input costs $0.042 per million tokens, and output tokens are free.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://typesafe.ai/blog/introducing-system-one-models-and-jev" rel="noopener noreferrer"&gt;Introducing System One models and Jev&lt;/a&gt;. TypeSafe's launch post explains the model class Jev belongs to, built to return structured decisions that software can use directly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Batch APIs
&lt;/h3&gt;

&lt;p&gt;Most providers sell batch processing at half price. The queue above works with any of them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://platform.claude.com/docs/en/build-with-claude/batch-processing" rel="noopener noreferrer"&gt;Anthropic Message Batches&lt;/a&gt;. Usage is billed at 50% of standard prices. A batch holds up to 100,000 requests or 256 MB, and most batches finish within an hour. The code in this article uses its create and results calls.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developers.openai.com/api/docs/guides/batch" rel="noopener noreferrer"&gt;OpenAI Batch API&lt;/a&gt;. Costs 50% less than the standard API, has its own higher rate limits and turns jobs around within 24 hours. Requests go in a JSONL file uploaded through the Files API, so the queue would write a file instead of an array.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.fireworks.ai/guides/batch-inference" rel="noopener noreferrer"&gt;Fireworks Batch API&lt;/a&gt;. Serverless prices are halved for open-weight and custom models. Input is a JSONL dataset of up to 80 GiB. Jobs expire after a period you choose between 12 and 72 hours. An expired job can be continued so that only its unfinished requests run again.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://ai.google.dev/gemini-api/docs/batch-api" rel="noopener noreferrer"&gt;Gemini Batch API&lt;/a&gt;. Asynchronous bulk jobs cost 50% of standard pricing. Google also offers &lt;a href="https://ai.google.dev/gemini-api/docs/optimization" rel="noopener noreferrer"&gt;Flex inference&lt;/a&gt; at the same discount for synchronous calls, which gives you a cheap awaitable call without writing a queue.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@vinch1910/treat-llm-output-as-a-build-artifact-batch-apis-and-jev-2aa0029befbe" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Have you shipped LLM output as a build artifact, or does it still run at request time for you? I'd like to hear where this pattern breaks.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
