<?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: Jacek Garbuliński</title>
    <description>The latest articles on DEV Community by Jacek Garbuliński (@jacek_garbuliski).</description>
    <link>https://dev.to/jacek_garbuliski</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%2F4258043%2Fe9ca4792-c49a-4037-ae61-fb4ae754b887.png</url>
      <title>DEV Community: Jacek Garbuliński</title>
      <link>https://dev.to/jacek_garbuliski</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jacek_garbuliski"/>
    <language>en</language>
    <item>
      <title>How to stop contact form spam without a CAPTCHA</title>
      <dc:creator>Jacek Garbuliński</dc:creator>
      <pubDate>Sun, 22 Nov 2026 02:17:21 +0000</pubDate>
      <link>https://dev.to/jacek_garbuliski/how-to-stop-contact-form-spam-without-a-captcha-2f9l</link>
      <guid>https://dev.to/jacek_garbuliski/how-to-stop-contact-form-spam-without-a-captcha-2f9l</guid>
      <description>&lt;p&gt;A contact form can bring spam submissions every day, like a message offering to spread links across the web for a fee, with every field filled in correctly: a name, an email address and a topic picked from the form's own list. Nobody typed it. A spam bot on a rented server found the form, filled it in and sent it, and someone at the company has to read and delete it. This post shows how to stop contact form spam without a CAPTCHA for your visitors, without cookies and without sending their data to anyone else, and how to tell after a week that it works.&lt;/p&gt;

&lt;p&gt;Google's &lt;a href="https://developers.google.com/recaptcha" rel="noopener noreferrer"&gt;reCAPTCHA&lt;/a&gt;, the "I'm not a robot" box or its invisible score, stands in front of every real visitor too, and loads Google's script and cookie with it.&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%2Fsvxz64trn7upe4julhod.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%2Fsvxz64trn7upe4julhod.png" alt="A reCAPTCHA challenge from around 2007: two warped words, &amp;quot;sClt&amp;quot; and &amp;quot;was here&amp;quot;, and a box to type them" width="312" height="123"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A reCAPTCHA challenge as it looked around 2007. Image: Wikimedia Commons, public domain.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On our form, a few simple checks do the work. A spam bot that posts straight to the form, without running the page, meets a honeypot field and a timestamp check signed by the server. One that runs the page meets an invisible proof-of-work CAPTCHA, a small puzzle the visitor's browser solves while they type, which took a fifth of a second in Chrome on a laptop. A spam filter for links catches what is left.&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%2Fk9qmw6oxtqot0bikadkh.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%2Fk9qmw6oxtqot0bikadkh.png" alt="The checks in the order the server makes them: a stream of posts narrowing at the honeypot field, the signed timestamp, the proof of work and the link rule, with what each one stops" width="800" height="772"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The checks in the order the server makes them, and what each one stops; not to scale&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The post is for small-business website owners getting contact form spam, on &lt;a href="https://wordpress.org/" rel="noopener noreferrer"&gt;WordPress&lt;/a&gt; with &lt;a href="https://contactform7.com/" rel="noopener noreferrer"&gt;Contact Form 7&lt;/a&gt;, &lt;a href="https://wpforms.com/" rel="noopener noreferrer"&gt;WPForms&lt;/a&gt; or &lt;a href="https://elementor.com/" rel="noopener noreferrer"&gt;Elementor&lt;/a&gt;, or on &lt;a href="https://webflow.com/" rel="noopener noreferrer"&gt;Webflow&lt;/a&gt;, and for the developers who look after their sites.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why bots spam contact forms
&lt;/h2&gt;

&lt;p&gt;The spam submission our form received was an advert: it offered to post links to the buyer's site in bulk across other websites, or to aim the same at a rival's site, sold as "a gift for a competitor". Behind such an offer is a program that fills in forms on other people's sites in bulk. A contact form is one more form to it, and the advert lands in front of a site owner who might buy. Ours came from a server rented from a hosting company.&lt;/p&gt;

&lt;p&gt;Blocking that server's address stops only that one; the next post can come from another. The checks below look at the post itself instead. Spam typed by a person passes all of them.&lt;/p&gt;
&lt;h2&gt;
  
  
  A honeypot field and a timestamp check stop the simplest spam bots
&lt;/h2&gt;

&lt;p&gt;A honeypot field is a form field that people never see and spam bots fill in: off the screen, skipped by the Tab key, labelled "Do not fill this field" for screen readers and not autofilled. A post with anything in it gets the usual thank-you page and nothing reaches the inbox, so the bot's owner sees no difference.&lt;/p&gt;

&lt;p&gt;A timestamp check, also called a time-trap, adds the time. When a visitor first clicks into the form, the page fetches the current time from our server, signed with a key only the server holds, and the post carries it back. A spam bot that posts straight to the form's address has no signed time, and a made-up one fails the signature. The post must also come a few seconds later, longer than a bot takes and shorter than the quickest person takes, and each signed time counts once. A time kept only in the page a bot can forge; signed by the server, it cannot be.&lt;/p&gt;

&lt;p&gt;Our form had a honeypot field before, and the advert still came through: the bot left the field empty. Neither check stops a bot that loads the page, leaves hidden fields empty and waits.&lt;/p&gt;
&lt;h2&gt;
  
  
  An invisible proof-of-work CAPTCHA costs visitors a moment and spam bots every message
&lt;/h2&gt;

&lt;p&gt;Proof of work replaces the puzzle a visitor solves with a sum the browser does. Along with the signed time, our server sends a random challenge. The browser tries number after number until one, hashed together with the challenge, gives a result that starts with a set run of zeros. That takes many thousands of tries, and the server checks the answer with one. The visitor sees nothing, no cookie is set, and nothing goes to anyone else.&lt;/p&gt;

&lt;p&gt;On a laptop the work took a median of 0.2 seconds in Chrome's engine and 0.05 in Safari's, while the visitor types, and the page keeps responding. With the processor slowed to imitate slower phones, the slowest run took 4 seconds; no real phone was measured.&lt;/p&gt;

&lt;p&gt;A spam bot that runs a full browser can do the work, so proof of work does not stop it, but every message costs it time. A browser that cannot do the work still sends the form, and the server asks the visitor to go back and send it again, or to write by email.&lt;/p&gt;
&lt;h2&gt;
  
  
  reCAPTCHA alternatives and what each costs your visitors
&lt;/h2&gt;

&lt;p&gt;A reCAPTCHA alternative changes what the visitor pays: a puzzle, a cookie, or data sent to another company. The figure sets five common services beside our own checks, as each describes itself on its own pages (read 21 November 2026); the table under it gives the details.&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%2Fppuivvc4me1k2xbh5oc1.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%2Fppuivvc4me1k2xbh5oc1.png" alt="Five reCAPTCHA alternatives and our checks, placed by what the visitor sees and where the visitor's data goes" width="800" height="682"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;What the visitor sees and where their data goes, with the price under each name&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  The details, service by service
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;What the visitor sees&lt;/th&gt;
&lt;th&gt;Cookies, in its own words&lt;/th&gt;
&lt;th&gt;Where the visitor's data goes&lt;/th&gt;
&lt;th&gt;Price&lt;/th&gt;
&lt;th&gt;How it tells bots from people&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://developers.google.com/recaptcha" rel="noopener noreferrer"&gt;reCAPTCHA&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;v2: the "I'm not a robot" box; v3: nothing but a badge&lt;/td&gt;
&lt;td&gt;sets &lt;code&gt;_GRECAPTCHA&lt;/code&gt; when it runs&lt;/td&gt;
&lt;td&gt;Google&lt;/td&gt;
&lt;td&gt;free to 10,000 checks a month, then $8 a month to 100,000&lt;/td&gt;
&lt;td&gt;a score from 0.0 to 1.0, with 0.5 as Google's suggested cut-off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.hcaptcha.com/" rel="noopener noreferrer"&gt;hCaptcha&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;free plan: an image puzzle; a mode without puzzles on Pro&lt;/td&gt;
&lt;td&gt;"consent-exempt" cookies and local storage&lt;/td&gt;
&lt;td&gt;mouse movements, scrolling and key presses, processed in the US&lt;/td&gt;
&lt;td&gt;free; Pro $99 a month, billed yearly&lt;/td&gt;
&lt;td&gt;the visitor's behaviour and the puzzle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://developers.cloudflare.com/turnstile/" rel="noopener noreferrer"&gt;Cloudflare Turnstile&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;usually nothing; a checkbox if the visitor looks risky&lt;/td&gt;
&lt;td&gt;a cookie only for its pre-clearance option&lt;/td&gt;
&lt;td&gt;IP address, connection fingerprint and browser name, to Cloudflare; not the form's entries&lt;/td&gt;
&lt;td&gt;free, unlimited&lt;/td&gt;
&lt;td&gt;checks run in the browser, proof of work among them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://altcha.org/" rel="noopener noreferrer"&gt;ALTCHA&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;its widget; the work runs in the background&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;your own server&lt;/td&gt;
&lt;td&gt;open-source core free; paid options&lt;/td&gt;
&lt;td&gt;proof of work, memory-hard if chosen&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://friendlycaptcha.com/" rel="noopener noreferrer"&gt;Friendly Captcha&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;nothing; checks run while the form is filled in&lt;/td&gt;
&lt;td&gt;none, and no consent needed&lt;/td&gt;
&lt;td&gt;the IP address, hashed; processed in the EU on its EU endpoint&lt;/td&gt;
&lt;td&gt;free for non-commercial use to 1,000 requests a month; from €9 a month&lt;/td&gt;
&lt;td&gt;proof of work and risk signals&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Our checks&lt;/td&gt;
&lt;td&gt;nothing&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;our own server&lt;/td&gt;
&lt;td&gt;our own code&lt;/td&gt;
&lt;td&gt;a honeypot field, a signed time, proof of work&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Our checks win on privacy and price: nothing leaves the server, no cookie is set, and nothing is paid. They lose to a spam bot that runs a full browser and waits. Each of the others is the better choice in some case:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://developers.cloudflare.com/turnstile/" rel="noopener noreferrer"&gt;Turnstile&lt;/a&gt;&lt;/strong&gt;, for bots that run a full browser: its checks look at the browser itself, for free, but every visitor's address and browser details go to Cloudflare.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://friendlycaptcha.com/" rel="noopener noreferrer"&gt;Friendly Captcha&lt;/a&gt;&lt;/strong&gt;, for the same bots on a European business site that would rather pay: it adds checks for automated browsers and proxies, and keeps the data in the EU on its EU endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.hcaptcha.com/" rel="noopener noreferrer"&gt;hCaptcha&lt;/a&gt;&lt;/strong&gt;, when bots get past invisible checks: its image puzzle asks for more than processor time, at the visitor's expense, and the data goes to the United States.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://developers.google.com/recaptcha/docs/v3" rel="noopener noreferrer"&gt;reCAPTCHA v3&lt;/a&gt;&lt;/strong&gt;, for a score per visit that your own code acts on: visitors see only the badge, but Google's cookie is set.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://altcha.org/" rel="noopener noreferrer"&gt;ALTCHA&lt;/a&gt;&lt;/strong&gt;, for what we built without writing it: proof of work on your own server, with a memory-hard option.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  A spam filter for links catches what gets through
&lt;/h2&gt;

&lt;p&gt;A spam bot that gets past the other checks still has to deliver its advert, and adverts look alike. Our form drops a message that puts a link in the name field, carries more than a few links, or pastes the link markup of forums and web pages. A real enquiry rarely does any of these; the advert from the first section did two of them, enough on its own to stop it. The sender sees the usual thank-you page, and the log notes the drop with its reason.&lt;/p&gt;

&lt;p&gt;A hosted filter such as &lt;a href="https://akismet.com/" rel="noopener noreferrer"&gt;Akismet&lt;/a&gt; judges the message's text on its own servers, so it can also catch spam typed by a person, which no check in this post stops. For that it receives the text, the sender's IP address and the browser's details.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to stop contact form spam on WordPress or in your own code
&lt;/h2&gt;

&lt;p&gt;Each setup gets a honeypot field and a time check first, then proof of work or a filter where the tool offers one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Contact Form 7:&lt;/strong&gt; install &lt;a href="https://wordpress.org/plugins/contact-form-7-honeypot/" rel="noopener noreferrer"&gt;CF7 Apps&lt;/a&gt; and use its Honeypot app with the submission time check on. For proof of work, the ALTCHA plugin below covers Contact Form 7.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WPForms:&lt;/strong&gt; its honeypot-based anti-spam protection and its minimum time to submit, 2 seconds by default, are on for new forms; check them under Settings » Spam Protection and Security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elementor:&lt;/strong&gt; add a Honeypot field to the Form widget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Webflow:&lt;/strong&gt; under Site settings » Apps &amp;amp; Integrations » Cloudflare Turnstile spam protection, turn on spam filtering and bot blocking, then publish the site.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof of work on WordPress without code:&lt;/strong&gt; the &lt;a href="https://altcha.org/docs/wordpress/" rel="noopener noreferrer"&gt;ALTCHA&lt;/a&gt; plugin runs on your own server with no outside service and covers Contact Form 7 and WPForms. It is installed from GitHub, not the plugin directory, and needs PHP 8.1 or later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your own code:&lt;/strong&gt; serve the site over HTTPS, which the browser's hashing needs, and follow the appendix, which has the checks in the order the server makes them; &lt;a href="https://github.com/blixild-jacek/form-proof-of-work" rel="noopener noreferrer"&gt;the full version&lt;/a&gt; on GitHub adds the rest, with tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After a week, count the posts by outcome: dropped by the honeypot, refused for no proof, dropped for a bad proof or by the link rule, and sent. A drop for a proof that was too fast or too old may be a real visitor, so check it against anyone who says a message did not arrive. If spam still reaches the inbox, a service from the table, or a filter such as Akismet, takes the next step.&lt;/p&gt;

&lt;p&gt;The form at the end of this post runs every one of these checks.&lt;/p&gt;
&lt;h2&gt;
  
  
  Appendix: example code
&lt;/h2&gt;

&lt;p&gt;The short version of the checks, to adapt. &lt;a href="https://github.com/blixild-jacek/form-proof-of-work" rel="noopener noreferrer"&gt;The full version&lt;/a&gt; on GitHub adds time limits, a fallback for older browsers, a store of used challenges for several servers, the honeypot field, the link rule and tests. The values are examples, not ours: tune them for your visitors.&lt;/p&gt;

&lt;p&gt;On the server, in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;base64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="no"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"FORM_PROOF_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# a long random secret in the server's settings, never in the code&lt;/span&gt;
&lt;span class="no"&gt;BITS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MIN_AGE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MAX_AGE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;     &lt;span class="c1"&gt;# example values: the work, and the seconds a post may come after&lt;/span&gt;
&lt;span class="no"&gt;FORMAT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"\A([0-9]{1,12})\.([0-9a-f]{16})\.([A-Za-z0-9_-]{22})\Z"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;used&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="c1"&gt;# challenge -&amp;gt; expiry; one process only, never emptied here&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;mac&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&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;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&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;base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urlsafe_b64encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&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="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;challenge&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="c1"&gt;# answer GET /form-proof with this as JSON, with Cache-Control: no-store&lt;/span&gt;
    &lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{int(time.time())}.{secrets.token_hex(8)}"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"c"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{head}.{sign(head)}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"bits"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;BITS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"min_age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;MIN_AGE&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;zero_bits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;byte&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;byte&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;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bit_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# "" when the proof holds, else why it does not&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"missing"&lt;/span&gt;  &lt;span class="c1"&gt;# answer with a message: go back to the form and send it again&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;FORMAT&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fullmatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"[0-9]{1,20}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compare_digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{m[1]}.{m[2]}"&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="mi"&gt;3&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="s2"&gt;"bad"&lt;/span&gt;
    &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="kt"&gt;int&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="mi"&gt;1&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="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;MIN_AGE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"fast"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;MAX_AGE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"old"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;zero_bits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hashlib&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;f&lt;/span&gt;&lt;span class="s2"&gt;"{c}:{x}"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&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="nf"&gt;digest&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;lt;&lt;/span&gt; &lt;span class="no"&gt;BITS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"work"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"used"&lt;/span&gt;
    &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;MAX_AGE&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the page, for each form marked &lt;code&gt;&amp;lt;form data-form-proof&amp;gt;&lt;/code&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="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;fetch&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;crypto&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subtle&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="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// no proof: the server answers with its message&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;enc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TextEncoder&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;job&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;pending&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;WeakSet&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;zeroBits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&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;new&lt;/span&gt; &lt;span class="nc"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&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="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&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="n"&gt;i&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="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&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;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&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="n"&gt;v&lt;/span&gt; &lt;span class="o"&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;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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;128&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;n&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&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;n&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;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;solve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// in slices of about 12 ms, so the page keeps responding&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;var&lt;/span&gt; &lt;span class="n"&gt;start&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="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&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="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;out&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;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&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="mi"&gt;256&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="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="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subtle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SHA-256"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;enc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;":"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;+&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="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;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;j&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="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&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="nf"&gt;zeroBits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&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="n"&gt;bits&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;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;j&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;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;12&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="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="kd"&gt;function&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="p"&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;r&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="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&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;function&lt;/span&gt; &lt;span class="nf"&gt;begin&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;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/form-proof"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"no-store"&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;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&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="nf"&gt;solve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min_age&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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;job&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="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;job&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;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&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="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'input[name="'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;input&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="s2"&gt;"hidden"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&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;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proved&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;pending&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;form&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestSubmit&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="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"focusin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&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;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;closest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"form[data-form-proof]"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;begin&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="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"submit"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&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="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"form[data-form-proof]"&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="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;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proved&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proved&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// the second pass, with the proof&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&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;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stopImmediatePropagation&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pending&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&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="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// a second click while the form waits&lt;/span&gt;
    &lt;span class="n"&gt;pending&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;begin&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;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;job&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="c1"&gt;// each challenge counts once&lt;/span&gt;
      &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&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;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"proof_c"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"proof_x"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&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="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&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="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;at&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;function&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;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&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="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;reCAPTCHA FAQ. Google for Developers. &lt;a href="https://developers.google.com/recaptcha/docs/faq" rel="noopener noreferrer"&gt;https://developers.google.com/recaptcha/docs/faq&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Proof-of-work CAPTCHA. ALTCHA documentation. &lt;a href="https://altcha.org/docs/integration/proof-of-work-captcha/" rel="noopener noreferrer"&gt;https://altcha.org/docs/integration/proof-of-work-captcha/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;How it works. ALTCHA documentation. &lt;a href="https://altcha.org/docs/how-it-works/" rel="noopener noreferrer"&gt;https://altcha.org/docs/how-it-works/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;reCAPTCHA v3. Google for Developers. &lt;a href="https://developers.google.com/recaptcha/docs/v3" rel="noopener noreferrer"&gt;https://developers.google.com/recaptcha/docs/v3&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Compare features between reCAPTCHA tiers. Google Cloud documentation. &lt;a href="https://docs.cloud.google.com/recaptcha/docs/compare-tiers" rel="noopener noreferrer"&gt;https://docs.cloud.google.com/recaptcha/docs/compare-tiers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloudflare Turnstile. Cloudflare Docs. &lt;a href="https://developers.cloudflare.com/turnstile/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/turnstile/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Turnstile plans. Cloudflare Docs. &lt;a href="https://developers.cloudflare.com/turnstile/plans/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/turnstile/plans/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Turnstile Privacy Addendum. Cloudflare. &lt;a href="https://www.cloudflare.com/turnstile-privacy-policy/" rel="noopener noreferrer"&gt;https://www.cloudflare.com/turnstile-privacy-policy/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;hCaptcha pricing. hCaptcha. &lt;a href="https://www.hcaptcha.com/pricing" rel="noopener noreferrer"&gt;https://www.hcaptcha.com/pricing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;hCaptcha FAQ. hCaptcha documentation. &lt;a href="https://docs.hcaptcha.com/faq" rel="noopener noreferrer"&gt;https://docs.hcaptcha.com/faq&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;hCaptcha Privacy Policy. hCaptcha. &lt;a href="https://www.hcaptcha.com/privacy" rel="noopener noreferrer"&gt;https://www.hcaptcha.com/privacy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Friendly Captcha. &lt;a href="https://friendlycaptcha.com/" rel="noopener noreferrer"&gt;https://friendlycaptcha.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GDPR. Friendly Captcha. &lt;a href="https://friendlycaptcha.com/privacy/gdpr/" rel="noopener noreferrer"&gt;https://friendlycaptcha.com/privacy/gdpr/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Use Akismet to filter contact form submissions. Akismet developer documentation. &lt;a href="https://akismet.com/developers/detailed-docs/building-your-application/use-akismet-to-filter-contact-form-submissions/" rel="noopener noreferrer"&gt;https://akismet.com/developers/detailed-docs/building-your-application/use-akismet-to-filter-contact-form-submissions/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;CF7 Apps: Addons for Contact Form 7 (Honeypot). WordPress.org plugin directory. &lt;a href="https://wordpress.org/plugins/contact-form-7-honeypot/" rel="noopener noreferrer"&gt;https://wordpress.org/plugins/contact-form-7-honeypot/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;How to Prevent Spam in WPForms. WPForms documentation. &lt;a href="https://wpforms.com/docs/how-to-prevent-spam-in-wpforms/" rel="noopener noreferrer"&gt;https://wpforms.com/docs/how-to-prevent-spam-in-wpforms/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Form widget. Elementor Help Center. &lt;a href="https://elementor.com/help/form-widget/" rel="noopener noreferrer"&gt;https://elementor.com/help/form-widget/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Prevent spam in form submissions. Webflow Help Center. &lt;a href="https://help.webflow.com/hc/en-us/articles/34277758554771-Prevent-spam-in-form-submissions" rel="noopener noreferrer"&gt;https://help.webflow.com/hc/en-us/articles/34277758554771-Prevent-spam-in-form-submissions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Introduction to ALTCHA for WordPress. ALTCHA documentation. &lt;a href="https://altcha.org/docs/wordpress/" rel="noopener noreferrer"&gt;https://altcha.org/docs/wordpress/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Get Started with WordPress. ALTCHA documentation. &lt;a href="https://altcha.org/docs/wordpress/get-started/" rel="noopener noreferrer"&gt;https://altcha.org/docs/wordpress/get-started/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Captchacat.png (a reCAPTCHA challenge, about 2007). Wikimedia Commons, public domain. &lt;a href="https://commons.wikimedia.org/wiki/File:Captchacat.png" rel="noopener noreferrer"&gt;https://commons.wikimedia.org/wiki/File:Captchacat.png&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>javascript</category>
      <category>python</category>
    </item>
    <item>
      <title>How a camera tracks the moving parts of a machine</title>
      <dc:creator>Jacek Garbuliński</dc:creator>
      <pubDate>Sun, 22 Nov 2026 00:25:51 +0000</pubDate>
      <link>https://dev.to/jacek_garbuliski/how-a-camera-tracks-the-moving-parts-of-a-machine-5814</link>
      <guid>https://dev.to/jacek_garbuliski/how-a-camera-tracks-the-moving-parts-of-a-machine-5814</guid>
      <description>&lt;p&gt;This post is for engineers who build or evaluate camera-based machine monitoring, computer vision specialists among them, and for production and maintenance managers who are considering a camera for machines with no PLC or data connection. A camera aimed at a machine can record when it runs and when it stands idle, with nothing wired into the machine. Our post on &lt;a href="https://blixild.com/machine-downtime-tracking-without-plc.html" rel="noopener noreferrer"&gt;machine monitoring without a PLC&lt;/a&gt; compares the camera with a current sensor and a stack light.&lt;/p&gt;

&lt;p&gt;Here we explain how a camera tracks the moving parts of a machine: how each part is defined without training data and followed in the image, how movement is told from noise, what the camera cannot see and how a tracker is tested. Engineers get the method and its limits; managers get what to ask a supplier and how monitoring is set up, from three stills of the machine to running time, idle time and a log of stoppages for each shift.&lt;/p&gt;

&lt;p&gt;The example throughout is a machine we monitor, with three heads that travel along rails. For each head, 15 times a second, the software works out where the head is and whether it is moving. When a movement ends, it records how far the head travelled, how fast, in which direction and for how long. Over a shift, these records add up to running time, idle time and the number of strokes per hour.&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%2Fx3br7qtv1pvd0v6zdrgw.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%2Fx3br7qtv1pvd0v6zdrgw.png" alt="From the camera image to shift figures" width="800" height="937"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;How the camera image becomes shift figures. On the right, the check that the box is still on the part.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why motion detection is not enough for machine monitoring
&lt;/h2&gt;

&lt;p&gt;The simplest camera method is motion detection. The software keeps a picture of the scene at rest and marks the pixels that differ from it in each new frame. Security cameras use it to start a recording. For a machine, it answers a different question from the one monitoring asks: it shows that something changed in an area of the image, not which part moved, how far or in which direction.&lt;/p&gt;

&lt;p&gt;Two parts in one area give one signal, and so do a part and the machine frame around it. A change of light, a shadow or a forklift driving past the machine also changes pixels, and the detector counts it as motion.&lt;/p&gt;

&lt;p&gt;Machine monitoring needs a measurement for each part: its position in every frame, and from that the start, end and length of each movement. That means following the part itself rather than the pixels that change around it. The rest of this post describes how.&lt;/p&gt;

&lt;h2&gt;
  
  
  Defining a part without training data
&lt;/h2&gt;

&lt;p&gt;The usual way to find an object in an image is a detector, trained on thousands of labelled pictures of the same kind of object. No such pictures exist for the parts of one machine, and every machine is different. Instead, a person defines each part once, on one frame from the camera: they draw a box around the part and pick at least five points on it. Nothing is trained, so the method needs no pictures of other machines of the same kind.&lt;/p&gt;

&lt;p&gt;The points have to sit where the surface has detail in two directions, such as the corner of a bracket or the head of a bolt. On flat paint the image looks the same wherever a point moves, and along a straight edge it looks the same when the point slides along the edge, so neither can be followed. The marking tool therefore snaps each click to a nearby spot with detail in two directions. On our machine, each head carries between 8 and 15 points.&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%2Fazhinfnhmog2q1ocbymc.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%2Fazhinfnhmog2q1ocbymc.png" alt="Three heads defined on one frame" width="800" height="742"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A frame from the camera above the machine, with the box and points of each head as they were defined. Below, the head in the dashed frame, enlarged.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In principle, two points fix the position and the angle of a rigid part. On a camera image, though, the points on one part lie close together, so an error of a fraction of a pixel in one of them shows up as a large error in the angle. The tracker therefore measures the angle only while at least four points survive, and asks for five or more, so that one hidden point does not stop the measurement.&lt;/p&gt;

&lt;p&gt;The frame on which the points are picked is kept as the part's first reference view: what the part looks like, as defined by the person who marked it. More views of the part, at another time of day or in another place on its rails, can be added. The tracker checks against them that the box is still on the part.&lt;/p&gt;

&lt;p&gt;The definition covers only what the camera sees. A part with no corners, such as a smooth painted cover, gives the points nothing to hold on to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Following the part from frame to frame
&lt;/h2&gt;

&lt;p&gt;Between two frames, each point is followed by optical flow: the software looks for the small shift that makes the pixels around the point in the new frame best match the pixels around it in the previous one. The method used, Lucas-Kanade, assumes that neighbouring pixels move together, which holds for a small patch on a rigid part. It finds only small shifts, so it works first on a reduced copy of the image, where a large move becomes a small one, and then refines the result on the full image.&lt;/p&gt;

&lt;p&gt;Optical flow says where the texture under a point went, not whether the match is real. Each point is therefore also followed backwards, from the new frame to the old one. If it does not come back to within half a pixel of where it started, the point is left out for that frame.&lt;/p&gt;

&lt;p&gt;The surviving points are then fitted together as one rigid body: the shift and turn that best carry them from where they were picked to where they are now. A point that disagrees with the rest, because it slipped onto the machine frame behind the part or was hidden, is put back where the others say it belongs. The box is attached to this fit. It keeps its drawn size, turns with the part, and its centre is the position that is measured.&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%2Fh3q9dn1095kpuil5so9p.jpg" 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%2Fh3q9dn1095kpuil5so9p.jpg" alt="The three heads tracked" width="704" height="396"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Video in the &lt;a href="https://blixild.com/how-a-camera-tracks-machine-parts.html" rel="noopener noreferrer"&gt;original post&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Five stretches from the camera above the machine, recorded on two days between 08:04 and 17:00, shown five times faster than real time, as the tracker followed the heads. A green box is moving, an orange box is at rest, and the line behind a box is its recent path.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Fitting all the points to the frame where they were picked keeps errors from adding up. Moving the box by each frame's average shift instead lets a small error in every frame accumulate, until the box and its own points end up tens of pixels apart.&lt;/p&gt;

&lt;p&gt;Following points cannot tell what they sit on. So in every frame the tracker also compares the image under the box with the part's reference views. If nothing matches them, it searches the image for the part; after five seconds without a match, it flags the part as unconfirmed and moves the box to where the search finds the part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Telling movement from noise
&lt;/h2&gt;

&lt;p&gt;Even a part that stands still does not stay on exactly the same pixel. Image noise, changes of light and video compression shift its measured position by a few hundredths of a pixel from frame to frame. A simple rule, moving when the position changes by more than a set amount in one frame, has to choose: set high, it misses a part that creeps slowly; set low, it fires on noise.&lt;/p&gt;

&lt;p&gt;The tracker instead adds up the part's movement frame by frame and compares the sum with the noise. Noise points one way, then another, so its sum grows slowly, with the square root of the number of frames. A real movement points the same way in every frame, so its sum grows in step with the number of frames. The part counts as moving when the sum passes four times the spread that noise alone would give it over that many frames. A slow creep passes this limit after enough frames; noise does not. The noise level itself is measured all the time, from how much the part's own points disagree with each other.&lt;/p&gt;

&lt;p&gt;The part is at rest again when its movement over the last two seconds stays within what noise alone would give, so two seconds of stillness end a movement.&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%2Frv7p7fw0rd9qxjwuob3o.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%2Frv7p7fw0rd9qxjwuob3o.png" alt="Movement added up against the noise limit" width="800" height="502"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Head 3 over seven seconds, measured. The vertical axis is how far the head has moved in total since the sum last started again, in pixels, on a scale where each grid line is ten times the one below. At rest, the sum stays under the noise limit and starts again every two seconds. When the head starts a stroke, the sum passes the limit at once.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;One more rule guards against very low noise. When the noise is very low, the limit is very low too, and a nudge of a fraction of a pixel can open a movement. Points that sit on a static patch of the machine can then log dozens of tiny movements every half hour.&lt;/p&gt;

&lt;p&gt;A movement counts only once the part has travelled 2 pixels of the analysed image at its furthest point, so that a stroke that goes out and comes back still counts. That removes most of the jitter and nothing a person would call a movement: the heads' real strokes are 60 to 100 pixels.&lt;/p&gt;

&lt;p&gt;The figures are in pixels of the image. How many millimetres a pixel is on the machine depends on the camera's distance and lens, and is not measured here.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the camera does not show
&lt;/h2&gt;

&lt;p&gt;The camera sees only what is in the picture, and only as clearly as the picture allows. These are the limits we have met:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A part that moves further between two frames than the flow can follow is lost for a moment and has to be found again by the search. Machine parts are usually slow enough; thrown or swung objects are not.&lt;/li&gt;
&lt;li&gt;While something stands in front of a part, the camera cannot tell whether the part moved.&lt;/li&gt;
&lt;li&gt;A second part that looks the same, such as an identical head on the same rail, can be taken for the part.&lt;/li&gt;
&lt;li&gt;In poor light, at dusk or at night, parts are harder to recognise, and a look-alike is easier to mistake for them.&lt;/li&gt;
&lt;li&gt;The measurements are in pixels. Turning them into millimetres needs the camera's distance and lens, as in our &lt;a href="https://blixild.com/machine-vision-lens-calculator.html" rel="noopener noreferrer"&gt;machine vision lens calculator&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;When a machine stops for a reason outside the picture, such as a busy crane or missing material, the camera records the stop but not its cause.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to check a tracker
&lt;/h2&gt;

&lt;p&gt;A tracker cannot be judged by its own output, because its own check can pass while the box sits in the wrong place. It has to be compared with something it did not produce.&lt;/p&gt;

&lt;p&gt;We compare ours with a reference that does not depend on it. A second, simpler method follows each part on every frame, using none of the tracker's rules, and leaves out any frame where it is unsure. A person then checks only a few frames per part by eye, chosen where mistakes are most likely: at rest, in the largest steps and where movements start. Nobody has to mark every frame by hand. A plain measure of where pixels changed inside each head's area, also worked out without the tracker, shows when a box reports rest while the head is moving.&lt;/p&gt;

&lt;p&gt;Three questions are worth asking about any camera-based monitoring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the system say when it is unsure, or does it always give a number?&lt;/li&gt;
&lt;li&gt;Was it checked against a reference it did not produce, on machines like yours?&lt;/li&gt;
&lt;li&gt;What does it not see, and how will you know when that happens?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Three camera approaches compared
&lt;/h2&gt;

&lt;p&gt;There are three common ways to follow a machine with a camera: motion detection, as built into most video recorders; a detector trained on labelled pictures, with a tracker that links its boxes from frame to frame; and a part tracker like ours, as described in this post.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;No.&lt;/th&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Motion detection&lt;/th&gt;
&lt;th&gt;Trained detector and tracker&lt;/th&gt;
&lt;th&gt;Our part tracker&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Which part moved, and how far&lt;/td&gt;
&lt;td&gt;No; it shows only that pixels changed in an area&lt;/td&gt;
&lt;td&gt;Yes, for the kinds of object it was trained on&lt;/td&gt;
&lt;td&gt;Yes, for each part named on the machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Training images&lt;/td&gt;
&lt;td&gt;None needed&lt;/td&gt;
&lt;td&gt;Many labelled pictures of each kind of object&lt;/td&gt;
&lt;td&gt;None; one frame, a box and at least five points per part&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Slow, small movements&lt;/td&gt;
&lt;td&gt;Missed, or mixed up with noise&lt;/td&gt;
&lt;td&gt;Hard to tell from the box's own jitter&lt;/td&gt;
&lt;td&gt;Added up and compared with the measured noise&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Says when it is unsure&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Gives a confidence score for each box&lt;/td&gt;
&lt;td&gt;Flags a part as unconfirmed after five seconds without a match&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Computer needed&lt;/td&gt;
&lt;td&gt;Usually built into the camera or recorder&lt;/td&gt;
&lt;td&gt;Usually one with a graphics card&lt;/td&gt;
&lt;td&gt;An ordinary computer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Motion detection is enough to see that something moved. To measure which part moved, how far and when it stopped, on a machine nobody has trained a detector for, each part has to be defined and followed on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  From tracks to shift figures
&lt;/h2&gt;

&lt;p&gt;Each movement the tracker records has a start, an end and a length. Added up over a shift, they give each part's running time, its idle time and its strokes per hour. Each stop becomes an entry in the log of stoppages, with its time, its duration and a video clip of the machine during the stop. Availability and OEE (overall equipment effectiveness) follow from there, as in our &lt;a href="https://blixild.com/oee-calculator.html" rel="noopener noreferrer"&gt;OEE calculator&lt;/a&gt;.&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%2Fvbx6rmxpwowcgry4k6ql.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%2Fvbx6rmxpwowcgry4k6ql.png" alt="Setting up machine monitoring with a camera" width="800" height="1563"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;How machine monitoring with a camera is set up, in five steps. The shift bar in step 5 is an illustration.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The place to start is one machine, the bottleneck, because it decides how much the plant produces. The camera on it shows where its time goes and which stop to fix first. What a fix is worth depends on the cost of an hour at that machine; our post on &lt;a href="https://blixild.com/machine-monitoring-payback-2-percent-oee.html" rel="noopener noreferrer"&gt;13 minutes a shift&lt;/a&gt; works it out for an example.&lt;/p&gt;

&lt;p&gt;For machines without a data interface, our &lt;a href="https://blixild.com/services.html#machine-monitoring" rel="noopener noreferrer"&gt;machine monitoring&lt;/a&gt; provides running and idle time for each shift and a log of stoppages with time, duration and a video clip.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Shi, J., Tomasi, C. (1993). Good Features to Track. Technical Report TR 93-1399, Cornell University. &lt;a href="https://users.cs.duke.edu/%7Etomasi/papers/shi/TR_93-1399_Cornell.pdf" rel="noopener noreferrer"&gt;https://users.cs.duke.edu/~tomasi/papers/shi/TR_93-1399_Cornell.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenCV (2026). Optical Flow. OpenCV 4.13.0 documentation, tutorials. &lt;a href="https://docs.opencv.org/4.x/d4/dee/tutorial_optical_flow.html" rel="noopener noreferrer"&gt;https://docs.opencv.org/4.x/d4/dee/tutorial_optical_flow.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>computervision</category>
      <category>machinelearning</category>
      <category>ai</category>
      <category>manufacturing</category>
    </item>
    <item>
      <title>How the basal LLM saves time and compute on text decisions</title>
      <dc:creator>Jacek Garbuliński</dc:creator>
      <pubDate>Sun, 22 Nov 2026 00:19:59 +0000</pubDate>
      <link>https://dev.to/jacek_garbuliski/how-the-basal-llm-saves-time-and-compute-on-text-decisions-1271</link>
      <guid>https://dev.to/jacek_garbuliski/how-the-basal-llm-saves-time-and-compute-on-text-decisions-1271</guid>
      <description>&lt;p&gt;Every support email is a customer waiting for help, and the wait grows when the email reaches the wrong team. A program can settle two questions as each email arrives: which team should handle it, and whether the customer has been cut off from the service.&lt;/p&gt;

&lt;p&gt;On an H200 graphics card, a generative model with 27 billion parameters took about 150 milliseconds to answer them: about 90 to read the email and its instructions, and 60 more to write a short answer token by token. basal, a decision model with 4.5 billion parameters, answered both questions on the same card in about 20 milliseconds and gave a probability for every option. A program that makes many such small decisions about texts, such as routing messages, checking a rule or choosing an agent's next step, can get each answer in a single pass of a small model, for a fraction of the computing work, and see how sure the model is.&lt;/p&gt;

&lt;p&gt;This guide shows how to use the basal LLM through an API and when it saves time and compute, measured against three generative models on the same 38 decisions. The main findings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;on the same card, basal answered in a seventh to a tenth of a 27B generative model's time, for a sixth to a ninth of its computing work;&lt;/li&gt;
&lt;li&gt;it got 35 of the 38 decisions right, where the two 27B generative models got all 38, and two of its misses came from one long-worded question;&lt;/li&gt;
&lt;li&gt;a short description of each option is what makes it route well;&lt;/li&gt;
&lt;li&gt;dates and amounts are best worked out in code and given to it as facts;&lt;/li&gt;
&lt;li&gt;through an API it is billed only for the text it reads, as it writes nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers who route or classify texts will find the first call and how to ask basal well. Those building agents will see how it picks the next step in one pass, and teams that run their own models what serving it behind a gateway takes. In order: what a decision model is, the first call, the comparison with generative models, how to ask basal, what we learned serving it, and where to start. For a generative model we serve that is made for Polish, see our guide to &lt;a href="https://blixild.com/bielik-api-guide.html" rel="noopener noreferrer"&gt;Bielik 11B v3.1 through an API&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A decision model answers in one pass with a probability per option
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/rkinas/basal" rel="noopener noreferrer"&gt;basal&lt;/a&gt; is a family of open decision models for Polish and English by Remigiusz Kinas. Its 2.0 models are built by further training of Bielik v3 and released under the Apache 2.0 licence. The family follows the idea of System 1 decision models such as TypeSafe's &lt;a href="https://docs.typesafe.ai/api" rel="noopener noreferrer"&gt;Jev&lt;/a&gt;, fast and intuitive rather than deliberate, and takes requests in Jev's System One format. We serve two of them: basal-2.0-4.5b, the main model, and basal-2.0-mini, with 1.5 billion parameters, the fastest. The software that serves them reached release 2.8.1 on 15 November 2026.&lt;/p&gt;

&lt;p&gt;A request carries a state, the text to decide about, and named questions about it. On our API a question is one of three kinds: yes or no, a choice among 2 to 255 options, or a level on a scale. basal itself knows more kinds, which the section on serving it returns to. The model reads the text and the questions once and returns, for each question, a probability for every allowed answer and the answer it picks. It writes nothing, so its answer cannot fall outside the options given, and several questions about one text take a single pass.&lt;/p&gt;

&lt;p&gt;The probabilities are calibrated: over many decisions, the answers given with a confidence of 0.9 are meant to be right about nine times in ten. That makes a threshold possible, above which decisions go ahead on their own while the rest go to a person.&lt;/p&gt;

&lt;p&gt;basal does not write text or give its reasons: a summary or an explanation still needs a generative model. It also picks an answer to every question, even one the text cannot settle, unless an option such as "none of these" is offered, and a low confidence is the sign of that. What it does return is easiest to see in a single call.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first basal LLM call through an API
&lt;/h2&gt;

&lt;p&gt;A call goes to api.blixild.com, our API's address, with a key from the dashboard after sign-in at &lt;a href="https://ai.blixild.com" rel="noopener noreferrer"&gt;Blixild AI&lt;/a&gt;. This one asks basal-2.0-4.5b two questions about one support email: which of five teams should handle it, and whether the service is down for the customer. Each team has a short description, and &lt;code&gt;"option_keys": "hide"&lt;/code&gt; shows the model only the descriptions, not the keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;teams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"billing"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Payments, top-ups and invoices"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"technical"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Technical problems with the API: errors, outages"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"account"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Account and API keys: sign-in, a leaked key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"sales"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Offer, prices, contracts and larger orders"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"other"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Spam and matters unrelated to the service"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hi, since this morning every request returns 'budget exceeded' "&lt;/span&gt;
         &lt;span class="s2"&gt;"and our chatbot is offline. We topped up $40 yesterday but the "&lt;/span&gt;
         &lt;span class="s2"&gt;"balance still shows $0."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;reply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"https://api.blixild.com/v1/systemone"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer YOUR_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"basal-2.0-4.5b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"questions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;"team"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"choice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"criteria"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;teams&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                     &lt;span class="s2"&gt;"instructions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Which team should handle it?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                     &lt;span class="s2"&gt;"option_keys"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"hide"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"down"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"noul"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                     &lt;span class="s2"&gt;"instructions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Is the service down for this customer?"&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&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;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"answers"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"usage"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"input_tokens"&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;The answers, shortened and with the probabilities rounded:&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;"team"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"choice"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"billing"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"confidence"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.61&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nl"&gt;"probabilities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"billing"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.61&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"technical"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="nl"&gt;"sales"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.06&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"account"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"other"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.02&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;"down"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"noul"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"probabilities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"true"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"false"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.12&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;basal sends the email to billing with 0.61 and to the technical team with 0.26: the message speaks of an error, but its cause is the balance. It is 88 percent sure that the customer is cut off. Both answers came from one pass over the email, which read 367 tokens and wrote none, so at our price for basal-2.0-4.5b, $0.10 per million input tokens, a thousand such emails cost about 3.7 cents.&lt;/p&gt;

&lt;p&gt;This is the System One format of Jev, so a request written for Jev's API, with yes or no, choice and score questions, runs on basal with a new address, key and model name. The same model also answers on &lt;code&gt;/v1/decisions&lt;/code&gt; in &lt;a href="https://developers.openai.com/api/docs/guides/decisions" rel="noopener noreferrer"&gt;OpenAI's Decisions format&lt;/a&gt;, with an &lt;code&gt;input&lt;/code&gt; and a list of &lt;code&gt;predicate&lt;/code&gt;, &lt;code&gt;choice&lt;/code&gt; and &lt;code&gt;score&lt;/code&gt; questions: our API translates between the two formats, so code for OpenAI's Decisions API that sends only text needs the same three changes.&lt;/p&gt;

&lt;p&gt;Through our API basal answers only those three kinds of question. Its other kinds, such as several labels at once, filling in fields from a document or picking an agent's next tool straight from the tool definitions, need a basal server of your own, and so do settings that apply to a whole request, such as its language, which our API ignores. Whether a program gains by sending them to basal rather than to a generative model depends on what each costs in time, work and money.&lt;/p&gt;

&lt;h2&gt;
  
  
  basal takes a fraction of a 27B generative model's time and work
&lt;/h2&gt;

&lt;p&gt;A generative model can make the same decisions, and many programs already ask one for them. To see what basal saves, we put the same 24 requests to basal and to three generative models we serve: 14 support emails, 11 in Polish and 3 in English, each asking for the team and whether the service is down, and 10 Polish messages to a shop's assistant, each asking for its next step among six tools, an answer or a question back to the customer. That makes 38 decisions with known answers.&lt;/p&gt;

&lt;p&gt;The generative models, Bielik 11B v3.1, &lt;a href="https://huggingface.co/Qwen/Qwen3.8-27B-FP8" rel="noopener noreferrer"&gt;Qwen3.8-27B&lt;/a&gt; and &lt;a href="https://huggingface.co/NousResearch/Arete-27B" rel="noopener noreferrer"&gt;Arete 27B&lt;/a&gt;, got the same descriptions of the options in a full instruction, a JSON format that allowed only those options, and thinking turned off. The requests went one at a time. The models run on different cards, basal and Qwen on an H200, Bielik on an RTX 5090 and Arete on an RTX 3090, and a time measured on one card says little about another.&lt;/p&gt;

&lt;p&gt;So the comparison uses two measures. Time is compared only between models on the same card, and it is measured on the machine itself, so the network is left out. The work behind a request is estimated as twice the model's parameters for every token it reads or writes, a rule of thumb that holds on any card.&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%2Feydwv8zjrmwp91hc3hic.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%2Feydwv8zjrmwp91hc3hic.png" alt="Work and time per decision request" width="800" height="549"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The figure shows two questions about one support email. The top chart gives the estimated work per request, from the model's size and the tokens it reads and writes, which is the same on any card. The bottom chart gives the model's own time per request, measured on the H200 machine itself. Bielik and Arete run on other cards, so their times are left out.&lt;/em&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Right, of 38&lt;/th&gt;
&lt;th&gt;Tokens in / out, per email&lt;/th&gt;
&lt;th&gt;Per 1,000 emails, our prices&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;basal-2.0-4.5b&lt;/td&gt;
&lt;td&gt;35&lt;/td&gt;
&lt;td&gt;342 / 0&lt;/td&gt;
&lt;td&gt;$0.034&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;basal-2.0-mini&lt;/td&gt;
&lt;td&gt;34&lt;/td&gt;
&lt;td&gt;342 / 0&lt;/td&gt;
&lt;td&gt;$0.017&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Qwen3.8-27B&lt;/td&gt;
&lt;td&gt;38&lt;/td&gt;
&lt;td&gt;310 / 13&lt;/td&gt;
&lt;td&gt;$0.082&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Arete 27B&lt;/td&gt;
&lt;td&gt;38&lt;/td&gt;
&lt;td&gt;310 / 13&lt;/td&gt;
&lt;td&gt;$0.051&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bielik 11B v3.1&lt;/td&gt;
&lt;td&gt;36&lt;/td&gt;
&lt;td&gt;1,481 / 14&lt;/td&gt;
&lt;td&gt;$0.30&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On the H200 machine itself, basal-2.0-4.5b answered the two questions about an email in about 20 milliseconds and chose the shop assistant's next step in about 10, where Qwen3.8-27B took about 150 and 120. That is a seventh to a tenth of the time, for a sixth to a ninth of the estimated work. Of Qwen's 150 milliseconds on an email, about 90 went on reading it with its instructions and 60 on writing a 13-token answer, while basal reads once and writes nothing.&lt;/p&gt;

&lt;p&gt;The two 27B generative models got all 38 decisions right, Bielik 36 and basal-2.0-4.5b 35. Two of basal's misses came from one question, whether the service is down, asked in a long wording with a description of each answer. Asked as a short question in our earlier tests, the same model got all 14 emails right. The third was a damaged order with a refund amount, which it sent to the complaints team instead of to a refund. The mini missed four, two of them on the shop assistant's next step.&lt;/p&gt;

&lt;p&gt;At Blixild AI's prices a decision costs less with basal than with any of the three generative models: 3.4 cents per thousand email requests, against 5.1 for Arete, 8.2 for Qwen and 30 for Bielik. The gap to Arete is small, because Arete reads about as many tokens and writes few. Bielik's is large, because its built-in guidelines add about a thousand tokens to every request and its input price is twice basal's. These prices are ours, set per model, not a property of the models.&lt;/p&gt;

&lt;p&gt;The comparison has its limits. The 38 decisions, in two kinds of task, are few, the wording and the descriptions were ours, and each generative model might do better with a prompt tuned for it. The work is an estimate that leaves out each model's numeric precision, and the time was measured one request at a time on the machine itself, not under a full load and without the network, which a program also waits for. Two of basal's three misses came from how it was asked, so the way a question is put is where its accuracy is won.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to ask basal so it decides well
&lt;/h2&gt;

&lt;p&gt;A decision model reads only what the request gives it, so most of its mistakes come from how a question is asked. basal's own guide and our tests point to the same habits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;give every option a short description: routing the 14 emails by the teams' names alone, asked in English, got 6 right, and with a description of each team, asked in Polish like most of the emails, all 14;&lt;/li&gt;
&lt;li&gt;keep a yes or no question short and to one condition: asked briefly whether the service was down, basal-2.0-4.5b got all 14 emails right, and in the longer wording of the comparison it missed two;&lt;/li&gt;
&lt;li&gt;ask all the questions about one text in one request, which reads the text once and gives the same answers faster;&lt;/li&gt;
&lt;li&gt;put the rules and facts a decision needs into the text, such as a return period or today's date, and write the question in the text's language, which basal follows;&lt;/li&gt;
&lt;li&gt;offer an option such as "cannot be determined" when the text may not hold the answer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Dates and amounts are its weak spot. On twelve Polish rules about deadlines and amounts, such as whether an invoice is overdue, the 4.5B got eight right as written and nine with the date or total worked out first. A rule like "overdue" is best decided in code, with basal reading the text around it.&lt;/p&gt;

&lt;p&gt;The confidence decides what goes ahead on its own. A question with &lt;code&gt;"max_error": 0.05&lt;/code&gt; comes back with &lt;code&gt;"abstain": true&lt;/code&gt; when basal is less sure than its threshold for a 5 percent error rate, and our API passes the setting on. Out of the box the threshold is cautious: both right answers in the example above abstained, and on kinds of question it was not trained on, the 4.5B decides about a third on its own. A threshold fitted on your own labelled texts, in your code on our API or with basal's calibration tool on your own server, matches the confidence to your data. basal's documentation says a few hundred labelled decisions usually suffice for the 5 percent target.&lt;/p&gt;

&lt;p&gt;The mini answers in about half the 4.5B's time and at half the price, and got 34 of the 38 decisions to the 4.5B's 35. It reads at most 8,192 tokens, the 4.5B 32,768, and a longer text is cut in the middle. A team that runs basal on its own server has more to choose from, and a few points to settle first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Serving basal behind an OpenAI-compatible API
&lt;/h2&gt;

&lt;p&gt;Such a team may want basal behind the same API, keys and billing as its generative models. We serve it through &lt;a href="https://docs.litellm.ai" rel="noopener noreferrer"&gt;LiteLLM&lt;/a&gt;, an open-source gateway that gives many models one OpenAI-style API, and five points from that work apply to anyone doing the same:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LiteLLM serves decision models on two routes of their own, &lt;code&gt;/v1/systemone&lt;/code&gt; and &lt;code&gt;/v1/decisions&lt;/code&gt;, with the usual keys, budgets and rate limits; its chat route refuses them, and it does not stream them;&lt;/li&gt;
&lt;li&gt;it passes yes or no, choice and score questions with their own fields, such as &lt;code&gt;option_keys&lt;/code&gt; and &lt;code&gt;max_error&lt;/code&gt;, and refuses basal's other kinds of question before the model sees them, while settings for a whole request, such as the language and basal's calculated facts, do not reach the model;&lt;/li&gt;
&lt;li&gt;a decision model writes nothing, so it needs a price per input token only, and a mark in its settings as a decision model, or LiteLLM's health check sends it a chat request it cannot answer;&lt;/li&gt;
&lt;li&gt;LiteLLM's TypeSafe provider, made for Jev, falls back to TypeSafe's own service when no address is set, so a mistyped setting would send customers' texts to a third party, while its Strands Decider provider, made for self-hosted decision models, has no default address and fails instead;&lt;/li&gt;
&lt;li&gt;basal's fast mode compiles the model when the server starts, which takes several minutes and needs a C compiler and Python's development headers on the machine, and in our measurements it answered 1.5 to 2 times faster, with probabilities within 0.04 of the uncompiled ones.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On a server of your own, basal's other kinds of question, its calculated facts for Polish dates and amounts and its calibration tool are all available. Through our API they are not, so where to start depends on what a program needs from basal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to start with decisions in basal
&lt;/h2&gt;

&lt;p&gt;For routing and classifying texts, basal pays off where the decisions are many and short, and where the options can be described in a sentence each. For an agent, it picks the next step in one pass and leaves the arguments of a tool call to a generative model or to code. For a team running its own models, the gateway's routes, the provider without a default address and the compiled mode are the parts to set up first. The first steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;List the decisions your program makes about texts, and write a short description for every option.&lt;/li&gt;
&lt;li&gt;Sign in at &lt;a href="https://ai.blixild.com" rel="noopener noreferrer"&gt;Blixild AI&lt;/a&gt;, where an API key and $1 of credit to start are ready at once.&lt;/li&gt;
&lt;li&gt;Send 20 to 50 of your own texts with known answers to basal-2.0-4.5b and basal-2.0-mini, as in the example above.&lt;/li&gt;
&lt;li&gt;Label a few hundred more as they come in, choose a confidence threshold from them or set &lt;code&gt;max_error&lt;/code&gt;, and send the decisions below it to a person.&lt;/li&gt;
&lt;li&gt;Move dates, amounts and other arithmetic into your code, and give basal the results.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;basal-2.0-4.5b and basal-2.0-mini run in Blixild AI on our H200 in Poland, at $0.10 and $0.05 per million input tokens, with nothing charged for output. We set up and run decision and generative models at a customer's site or in their own cloud account as part of our &lt;a href="https://blixild.com/services.html#hosting" rel="noopener noreferrer"&gt;AI workload hosting&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Kinas, R. (2026). basal 2.8.1, README. &lt;a href="https://github.com/rkinas/basal/blob/v2.8.1/README.md" rel="noopener noreferrer"&gt;https://github.com/rkinas/basal/blob/v2.8.1/README.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Kinas, R. (2026). basal 2.8.1, API. &lt;a href="https://github.com/rkinas/basal/blob/v2.8.1/docs/API.md" rel="noopener noreferrer"&gt;https://github.com/rkinas/basal/blob/v2.8.1/docs/API.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Kinas, R. (2026). basal 2.8.1, question types. &lt;a href="https://github.com/rkinas/basal/blob/v2.8.1/docs/QUESTION_TYPES.md" rel="noopener noreferrer"&gt;https://github.com/rkinas/basal/blob/v2.8.1/docs/QUESTION_TYPES.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Kinas, R. (2026). basal 2.8.1, calibration on your own data. &lt;a href="https://github.com/rkinas/basal/blob/v2.8.1/docs/CALIBRATION.md" rel="noopener noreferrer"&gt;https://github.com/rkinas/basal/blob/v2.8.1/docs/CALIBRATION.md&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Kinas, R. (2026). basal-2.0-4.5B, model card. &lt;a href="https://huggingface.co/Remek/basal-2.0-4.5B" rel="noopener noreferrer"&gt;https://huggingface.co/Remek/basal-2.0-4.5B&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LiteLLM (2026). /v1/decisions and /v1/systemone. &lt;a href="https://docs.litellm.ai/docs/decisions" rel="noopener noreferrer"&gt;https://docs.litellm.ai/docs/decisions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenAI (2026). Decisions API guide. &lt;a href="https://developers.openai.com/api/docs/guides/decisions" rel="noopener noreferrer"&gt;https://developers.openai.com/api/docs/guides/decisions&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
      <category>performance</category>
    </item>
    <item>
      <title>How to build a self-hosted LLM API, from GPU to customer</title>
      <dc:creator>Jacek Garbuliński</dc:creator>
      <pubDate>Sun, 22 Nov 2026 00:14:10 +0000</pubDate>
      <link>https://dev.to/jacek_garbuliski/how-to-build-a-self-hosted-llm-api-from-gpu-to-customer-512a</link>
      <guid>https://dev.to/jacek_garbuliski/how-to-build-a-self-hosted-llm-api-from-gpu-to-customer-512a</guid>
      <description>&lt;p&gt;A model on your own graphics card can answer your team or paying customers through an API, with a key for each of them, a price per token and a stop when the credit runs out, while the card itself never gets an address on the internet. A handful of open-source tools and a payment provider make that possible, and each of them has a setting that is easy to get wrong.&lt;/p&gt;

&lt;p&gt;This post goes through them in the order to build them, as they run behind &lt;a href="https://ai.blixild.com" rel="noopener noreferrer"&gt;Blixild AI&lt;/a&gt;, our self-hosted LLM API for open models on RTX 3090s and RTX 5090s in our own servers in Poland. At each stop of a request I say what the tool does, why I chose it and what to take care of.&lt;/p&gt;

&lt;p&gt;Along the way the post shows where a card had a quarter less room for conversations than our own calculator estimated, and why a model server's own key check does not protect it. It explains why a long prompt can stall where short requests pass and why every payment arrives twice. It ends with what a setup for one person or one company can leave out, and with the six steps of the build.&lt;/p&gt;

&lt;p&gt;I wrote it for engineers who want to put an open model behind an API, for their own company or for customers. An &lt;a href="https://blixild.com/arete-27b-api-rtx-3090.html" rel="noopener noreferrer"&gt;earlier post&lt;/a&gt; explains why we serve Arete 27B this way.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a model API needs beyond the model
&lt;/h2&gt;

&lt;p&gt;Serving software loads a model onto a graphics card (GPU) and answers requests. A service needs more than that. Somebody has to know who is asking, count the tokens, put a price on them and stop when the credit runs out. Customers need a way to sign in and to pay, and I need to know that all of it works.&lt;/p&gt;

&lt;p&gt;I followed one rule: a ready-made tool for every job, and my own code only where the tools meet. The figure shows the result along the path of one request. A small server in Helsinki is the only machine the internet can reach, and the cards sit behind it. The sections below take the stops in the order I built them, from the cards outwards: the card and its model server, the gate in front of it, the gateway that charges for tokens, the portal where customers sign in, and the checks that hold them together.&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%2F1y55tkv38s2vz10vclvn.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%2F1y55tkv38s2vz10vclvn.png" alt="The stack along the path of one request" width="800" height="769"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The figure shows the path of one request and the tool at each stop. It is an illustration, not a measurement.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The calculator sizes the card and the endpoint checks it
&lt;/h2&gt;

&lt;p&gt;The first stop is the card, and the first question is whether the model fits on it and how fast it will answer. Our &lt;a href="https://blixild.com/llm-gpu-token-speed-calculator.html" rel="noopener noreferrer"&gt;LLM GPU Token Speed Calculator&lt;/a&gt; estimates both before anything is loaded. It takes the card, the model, the size of its weights and the number of requests at once. It returns the memory left for conversations, the time to the first token and the tokens per second each user gets.&lt;/p&gt;

&lt;p&gt;For this post I entered the RTX 3090's setup with Arete 27B and wrote the results down before I compared them with the measurements. The table shows both.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Calculator, practical range&lt;/th&gt;
&lt;th&gt;Endpoint, measured&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Room for conversations&lt;/td&gt;
&lt;td&gt;147,000 to 174,000 tokens&lt;/td&gt;
&lt;td&gt;109,000 tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed of one request&lt;/td&gt;
&lt;td&gt;43.0 to 47.1 tokens/s&lt;/td&gt;
&lt;td&gt;46.9 tokens/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed of each of two long requests at once&lt;/td&gt;
&lt;td&gt;39.3 to 43.6 tokens/s&lt;/td&gt;
&lt;td&gt;40.8 tokens/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First token after a 1,000-token prompt&lt;/td&gt;
&lt;td&gt;0.71 to 0.77 s&lt;/td&gt;
&lt;td&gt;0.79 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The speeds fell inside the calculator's range, and the first token came 2% later than the range's upper end. The room for conversations did not match: the endpoint had about a quarter less than the lowest estimate. The serving software's start-up log shows where the difference lies. The software reserved about three times the working memory that the calculator assumed for a text-only model.&lt;/p&gt;

&lt;p&gt;The calculator's practical estimate now counts that larger working memory. For the same setup it gives about 96,000 to 105,000 tokens, just below the endpoint's 109,000.&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%2Fhhfsakz0m9rubmlxcxi5.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%2Fhhfsakz0m9rubmlxcxi5.png" alt="The calculator's Memory step for Arete 27B on an RTX 3090" width="800" height="934"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The figure is a screenshot of the calculator's Memory step for Arete 27B in 4 bits on an RTX 3090, with an 8-bit conversation memory, text only and a 98.9% memory share. It shows the estimate as the calculator gives it since the comparison above.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;An estimate chooses the card. It does not set the service's limits. Those come from a run with every slot busy and the longest prompts the model accepts, because that run shows the memory left at the worst moment. Neither the estimate nor these measurements say how well the model answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  vLLM serves one model on each card
&lt;/h2&gt;

&lt;p&gt;With the card chosen, the next choice is the software that loads the model onto it and answers requests. I use &lt;a href="https://docs.vllm.ai/" rel="noopener noreferrer"&gt;vLLM&lt;/a&gt;, because it answers several requests at once from one card and speaks the same format as OpenAI's API. One vLLM process serves one model, so a card holds one model: Arete 27B runs on an RTX 3090 and Bielik 11B v3.1 on an RTX 5090.&lt;/p&gt;

&lt;p&gt;Each model has to fit its card. Bielik fits the 5090's 32 GB with its weights stored in 8 bits each. Arete 27B at full precision needs more than twice the 3090's 24 GB, so that card runs a 4-bit build. A 4-bit build can cost some accuracy, and I have not yet measured how much for Arete.&lt;/p&gt;

&lt;p&gt;What the weights leave free holds the conversations in progress. On the 3090, storing that conversation memory in 8 bits and leaving out the model's image input about doubled the room. vLLM can also draft several tokens per step, which on that card was about one and a half times faster for a single request and cost 60% of that room. I chose the room, because long documents and agents need it.&lt;/p&gt;

&lt;p&gt;Two settings deserve care:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set the conversation memory yourself.&lt;/strong&gt; By default vLLM measures its working memory at each start and gives conversations the rest. The measurement can differ between starts, and a start that gives conversations too much runs out of memory. A fixed size, taken from a run that held with every slot busy, starts the same way every time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switch tool calling on and test it.&lt;/strong&gt; It works only when vLLM starts with the parser for the model's format, and the two models here need different ones. Without it, plain chat works and every request that offers tools fails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these settings the model answers anyone who can reach its port. The next stop decides who can.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cards stay off the internet
&lt;/h2&gt;

&lt;p&gt;vLLM can check an API key itself, but that option guards only some of its addresses. Others on the same port answer without a key, among them one that generates text. vLLM's own documentation says not to rely on the option alone and to put a reverse proxy in front.&lt;/p&gt;

&lt;p&gt;I put &lt;a href="https://nginx.org/" rel="noopener noreferrer"&gt;nginx&lt;/a&gt; there as a key gate, the same on every GPU server. It passes requests under /v1 that carry a known key and refuses everything else. vLLM listens only on the machine itself, so the gate is the only way in.&lt;/p&gt;

&lt;p&gt;Only one machine needs to reach the gate: the gateway server in Helsinki. It connects over &lt;a href="https://tailscale.com/" rel="noopener noreferrer"&gt;Tailscale&lt;/a&gt;, a private encrypted network between our machines. The network's access policy lets the gateway reach that one port on each GPU server and nothing else, and the policy has tests that fail if a change opens more. Check the plan before a service depends on it: Tailscale's free plan is for non-commercial use.&lt;/p&gt;

&lt;p&gt;The gate only decides who gets in. It holds no budgets and counts no tokens, and that is the gateway's job.&lt;/p&gt;

&lt;h2&gt;
  
  
  LiteLLM turns tokens into charges
&lt;/h2&gt;

&lt;p&gt;The gateway is &lt;a href="https://docs.litellm.ai/" rel="noopener noreferrer"&gt;LiteLLM&lt;/a&gt;, an open-source proxy for model APIs. Each model is one entry in its config, with the address and the key of the server that runs it, so a request that names Bielik goes to a 5090 and one that names Arete to a 3090.&lt;/p&gt;

&lt;p&gt;LiteLLM issues the keys customers use, counts each request's tokens, charges them against the customer's budget and refuses requests when the budget is spent, and it limits how many requests a key runs at once. &lt;a href="https://caddyserver.com/" rel="noopener noreferrer"&gt;Caddy&lt;/a&gt;, a web server, stands in front of it, obtains the TLS certificates and forwards only the /v1 addresses. Both run in containers on the gateway server, next to a &lt;a href="https://www.postgresql.org/" rel="noopener noreferrer"&gt;PostgreSQL&lt;/a&gt; database. The gateway and the portal have a server to themselves.&lt;/p&gt;

&lt;p&gt;Three things need care here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Price every custom model before you give credit.&lt;/strong&gt; LiteLLM knows the prices of public models. A custom model has no price until both of its rates are in the config, and a request without a price draws nothing from the credit. My check sends a real request to every model and compares the charge with its published price.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publish /v1 only.&lt;/strong&gt; LiteLLM's admin API manages keys and budgets, so it stays on the private side, where only the portal calls it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test the longest prompt through every hop.&lt;/strong&gt; A long prompt is a large upload, and it can stall in a layer that short requests never stress. With &lt;a href="https://docs.docker.com/engine/security/rootless/" rel="noopener noreferrer"&gt;rootless Docker&lt;/a&gt; that layer was &lt;a href="https://passt.top/" rel="noopener noreferrer"&gt;pasta&lt;/a&gt;, the user-mode network between a container and the host. Timing each hop separately found it, and switching the network back end to &lt;a href="https://github.com/rootless-containers/slirp4netns" rel="noopener noreferrer"&gt;slirp4netns&lt;/a&gt; fixed it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;LiteLLM does not load or swap models, and it does not sign anyone in or take a payment. Something has to create each customer and raise the budget when they pay, and that is the portal.&lt;/p&gt;

&lt;h2&gt;
  
  
  The portal handles sign-in, credit and payments
&lt;/h2&gt;

&lt;p&gt;The portal at ai.blixild.com is the part I wrote: a &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; application with &lt;a href="https://better-auth.com/" rel="noopener noreferrer"&gt;Better Auth&lt;/a&gt; for sign-in. Customers sign in with Google or GitHub only, so the portal stores no passwords and every email address arrives verified. On the first visit it creates the customer in LiteLLM with a key and $1 of credit.&lt;/p&gt;

&lt;p&gt;Credit is a ledger of grants in the portal's own database, and each grant sets the customer's budget in LiteLLM to the sum of the ledger. Customers add credit by paying through &lt;a href="https://stripe.com/" rel="noopener noreferrer"&gt;Stripe&lt;/a&gt;, which acts as merchant of record: it sells the credit in its own name, works out and pays the buyer's VAT or sales tax and sends the receipt.&lt;/p&gt;

&lt;p&gt;Three things need care here too:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expect every payment twice.&lt;/strong&gt; A payment is reported when the customer returns from the payment page and again through Stripe's webhook, which Stripe repeats when it gets no answer. Each grant therefore carries the payment's reference and counts once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Say whether tax is included.&lt;/strong&gt; Unless the call states it, the Stripe account's default decides whether tax is inside the price or added to it, and a test account and a live one can differ.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit the dependencies before launch.&lt;/strong&gt; A project that starts from a template or an example inherits the versions of the day that was written, and some of them will have known security holes by now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The portal sells prepaid credit only. It has no subscriptions and issues no invoices of its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  One check proves the whole path
&lt;/h2&gt;

&lt;p&gt;That completes the path, from the portal's sign-in to the card. Each tool on it passes its own tests, and the service can still fail between them. So one check runs the whole path against the real models, through the public address. It signs up a throwaway customer and makes a paid request. It verifies that the charge matches the published price, that requests stop at $0 and that a deleted key no longer works. Last, it confirms that the logs do not hold the prompt. The privacy promise rests on settings, and this check proves them after every change.&lt;/p&gt;

&lt;p&gt;In operation, the gateway keeps sending a short real request to each model, along the path customers use. A model that stops answering triggers an email, sent from the gateway's side, so the alert does not depend on the machine it reports on.&lt;/p&gt;

&lt;p&gt;One detail deserves a deliberate test. A restart rule that waits for an error code misses a model server that shuts down cleanly after its engine has died. I found this by stopping the engine on purpose, and the containers now restart whenever they stop.&lt;/p&gt;

&lt;p&gt;None of these checks measures how good the answers are. That takes tests of the model itself, on the work it will be used for.&lt;/p&gt;

&lt;h2&gt;
  
  
  A smaller setup needs fewer stops
&lt;/h2&gt;

&lt;p&gt;Blixild AI sells access to people I have never met, so it needs every stop above. A setup with fewer strangers needs fewer stops, and the same order tells which ones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One person, one machine.&lt;/strong&gt; The card, its sizing and vLLM are the whole stack while the model is used on the machine it runs on. Once a laptop or a phone should reach it, add the key gate and the private network, and nothing else. Blixild AI ran this way before it had customers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A company serving its own staff and applications.&lt;/strong&gt; Keep the gate and the private network, and add the gateway. Its keys then stand for a team or an application instead of a customer. Its budgets and its limit on requests at once keep one script from taking the whole card, and its usage records show who needs how much, which is what a decision on a second card rests on. Leave out the portal and the payments, because the staff already have accounts and nobody pays by card.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Six steps from a card to a service
&lt;/h2&gt;

&lt;p&gt;The path of this post is also the path of a build, from the card outwards, with each step proved before the next. How far you follow it depends on who will call the model. One person needs steps 1 to 3, a company serving its own staff needs steps 1 to 4, and a public service needs all of them. Step 6 belongs to every size.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Size the card.&lt;/strong&gt; Estimate whether the model fits and how fast it answers, then measure it with every slot busy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serve the model.&lt;/strong&gt; Run one model per card, set its conversation memory and test tool calling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protect the model server.&lt;/strong&gt; Put a key gate in front of it and reach it over a private network.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Meter the use.&lt;/strong&gt; Add a gateway that issues keys, prices tokens and enforces budgets, and decide what its logs may hold. Prove it with one test customer, down to the refusal at $0.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publish the service.&lt;/strong&gt; Give it a public address that forwards only the API, then add sign-in, credit and payments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the whole path.&lt;/strong&gt; Run one check from end to end after every change, and keep a real request going to each model.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each further card repeats steps 1 to 3 and adds one entry to the gateway's config.&lt;/p&gt;

&lt;p&gt;To see the result from the customer's side, sign in at &lt;a href="https://ai.blixild.com" rel="noopener noreferrer"&gt;ai.blixild.com&lt;/a&gt; with Google or GitHub. The key comes with $1 of credit and no card is needed, and any OpenAI client library works with api.blixild.com/v1.&lt;/p&gt;

&lt;p&gt;If you want this stack on your own premises or in your own cloud account, with the model of your choice, our &lt;a href="https://blixild.com/services.html#hosting" rel="noopener noreferrer"&gt;AI workload hosting&lt;/a&gt; sets it up and runs it for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;vLLM (2026). Security, read on 19 November 2026. &lt;a href="https://docs.vllm.ai/en/latest/usage/security.html" rel="noopener noreferrer"&gt;https://docs.vllm.ai/en/latest/usage/security.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LiteLLM (2026). Custom LLM Pricing. &lt;a href="https://docs.litellm.ai/docs/proxy/custom_pricing" rel="noopener noreferrer"&gt;https://docs.litellm.ai/docs/proxy/custom_pricing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LiteLLM (2026). Spend Tracking. &lt;a href="https://docs.litellm.ai/docs/proxy/cost_tracking" rel="noopener noreferrer"&gt;https://docs.litellm.ai/docs/proxy/cost_tracking&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Tailscale (2026). Tailscale pricing, read on 19 November 2026. &lt;a href="https://tailscale.com/pricing" rel="noopener noreferrer"&gt;https://tailscale.com/pricing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Stripe (2026). How Managed Payments works. &lt;a href="https://docs.stripe.com/payments/managed-payments/how-it-works" rel="noopener noreferrer"&gt;https://docs.stripe.com/payments/managed-payments/how-it-works&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
    <item>
      <title>How long does Qwen3.8-27B take with a long document?</title>
      <dc:creator>Jacek Garbuliński</dc:creator>
      <pubDate>Sun, 22 Nov 2026 00:14:01 +0000</pubDate>
      <link>https://dev.to/jacek_garbuliski/how-long-does-qwen38-27b-take-with-a-long-document-1kll</link>
      <guid>https://dev.to/jacek_garbuliski/how-long-does-qwen38-27b-take-with-a-long-document-1kll</guid>
      <description>&lt;p&gt;A contract bundle or a product manual can go into one request to a language model, so the answer draws on all of it and nobody has to build a search over the documents first. &lt;a href="https://huggingface.co/Qwen/Qwen3.8-27B-FP8" rel="noopener noreferrer"&gt;Qwen3.8-27B&lt;/a&gt; takes up to 262,144 tokens in one request, about the whole first volume of Bolesław Prus's &lt;em&gt;Lalka&lt;/em&gt; (&lt;em&gt;The Doll&lt;/em&gt;), a classic Polish novel. On one H200 graphics card it started answering a question about that volume after 52 seconds, and it answered the next question about it after 1.3 seconds. How much of that wait a team pays for depends on how it sends its questions.&lt;/p&gt;

&lt;p&gt;This guide shows how long Qwen3.8-27B takes to answer about long documents, how reliably it finds what is in them and what each question costs, from our measurements in Polish and English. The main findings:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Qwen3.8-27B on one H200&lt;/th&gt;
&lt;th&gt;What we measured&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;First answer, 131,000-token document&lt;/td&gt;
&lt;td&gt;17 to 18 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First answer, 260,000-token document&lt;/td&gt;
&lt;td&gt;52 to 55 seconds: twice the text took about three times as long&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Later questions about the same document&lt;/td&gt;
&lt;td&gt;0.6 to 1.6 seconds, with one exception, because the server keeps what it has read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Facts planted in a novel and a manual&lt;/td&gt;
&lt;td&gt;It found all of them and said so when a fact was not there&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Input cost of one question, 260,000 tokens&lt;/td&gt;
&lt;td&gt;About $0.05 at $0.20 per million tokens, because every question sends the whole document again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Other requests on the same card&lt;/td&gt;
&lt;td&gt;A long document slows them, and one setting shares the card between them&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These figures come from our own runs on one card: each length was measured once per text and language, on two texts, with questions that look up one fact, and at times with other requests running on the card. They show what working with the model looks like, the size of the waits and what reusing a document already read saves, rather than exact values. Firm numbers would take benchmark work: many runs of each setting, more kinds of documents and questions, and other cards and loads.&lt;/p&gt;

&lt;p&gt;It is written for developers deciding whether to send whole documents to a model or to search them first, for teams running Qwen3.8-27B on their own graphics card, and for those calling it through &lt;a href="https://ai.blixild.com" rel="noopener noreferrer"&gt;Blixild AI&lt;/a&gt;. For documents of up to 32,000 tokens and a smaller model, see our &lt;a href="https://blixild.com/bielik-api-guide.html" rel="noopener noreferrer"&gt;Bielik API guide&lt;/a&gt;. The sections cover, in order: what fits in one request, how reliably the model finds a fact, how the wait grows with the length, what later questions cost in time and money, running the model yourself, and where to start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qwen3.8-27B's context window holds 262,144 tokens
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://huggingface.co/Qwen/Qwen3.8-27B-FP8" rel="noopener noreferrer"&gt;Qwen3.8-27B&lt;/a&gt; is an open model from the Qwen team, published under the Apache 2.0 licence, and Blixild AI serves its FP8 build, in which most weights take one byte each. One request holds up to 262,144 tokens, the model's context window, and the question, the document and the answer all count towards that limit. The first volume of &lt;em&gt;Lalka&lt;/em&gt;, 123,000 Polish words, comes to 261,000 tokens, about 2.1 tokens a word; English prose takes fewer, about 1.4 tokens a word in Jane Austen's &lt;em&gt;Pride and Prejudice&lt;/em&gt;. Text dense with numbers takes more: our test manual took about 1.7 tokens a word in English and 2.3 in Polish.&lt;/p&gt;

&lt;p&gt;Qwen3.8-27B reasons before every answer unless it is told not to, which spends time and tokens on a question that only looks something up. One field turns the reasoning off, and our measurements below were all made that way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.blixild.com/v1/chat/completions \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $BLIXILD_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model": "qwen3.8-27b",
       "chat_template_kwargs": {"enable_thinking": false},
       "messages": [{"role": "user", "content":
         "Document:\n\nSection 12. The generator service contract was signed with Voltaris under number VLT-2291.\n\nQuestion: Under what number was the generator service contract signed? Answer briefly, from the document only. If the document does not say, write that it is not in it."}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In practice the whole document stands where the one-line section is, read from a file by the program that sends the request. How well the model uses the whole length is the next question.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qwen3.8-27B finds a fact at the start, middle and end of a long document
&lt;/h2&gt;

&lt;p&gt;A long prompt is only useful if the model reads all of it, including the middle. We tested that on &lt;em&gt;Lalka&lt;/em&gt;, cut at about 4,000, 130,000 and 258,000 tokens, and on a generated company manual full of look-alike inventory and contract numbers, at about the same lengths in English and in Polish. Into each text we planted three invented sentences at 10, 50 and 90 % of its length, such as the inventory number of an antique clock, so the model could not answer from what it had learned about the novel. Each was asked about in its own request, and a fourth question asked about an object the text does not mention.&lt;/p&gt;

&lt;p&gt;Qwen3.8-27B found all 27 planted facts and named each one exactly, such as the clock's number INW-4817. To each of the nine questions about the missing object it answered that the document does not say, rather than offering a number from a nearby passage. The test covers look-ups only, one fact per question, once per length, and no summaries or calculations across a document. Finding the fact was not the limit in this test, and the time to get it was.&lt;/p&gt;

&lt;h2&gt;
  
  
  The time to first token grows faster than the document
&lt;/h2&gt;

&lt;p&gt;Before the first word of an answer, the model reads the whole prompt, so the time to first token, the wait until the answer starts, grows with the document. We measured it on the graphics card itself, without a network in between: 0.2 to 0.3 seconds for 4,000 tokens, 17 to 18 seconds for 131,000 and 52 to 55 seconds for 260,000. Twice the document took about three times as long. Once the answer had started, a short answer of a few words was complete within a tenth of a second; with short prompts the model writes about 164 tokens a second in Polish and 191 in English.&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%2Fr9argq6s1zfgat7d14gg.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%2Fr9argq6s1zfgat7d14gg.png" alt="Two bar charts on one scale: the time to the first word of the answer for the first question about a document and for each later question, at 4,000, 130,000 and 258,000 tokens" width="800" height="462"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Measured on one H200 card with Qwen3.8-27B and the first volume of Lalka cut to three lengths, reasoning off. Both charts share one scale; each later question is the mean of three.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Our &lt;a href="https://blixild.com/llm-gpu-token-speed-calculator.html" rel="noopener noreferrer"&gt;LLM GPU token speed calculator&lt;/a&gt; estimates this wait for other graphics cards and models. For Qwen3.8-27B on an H200 with a 254,000-token prompt it gives 45 to 46 seconds, where we measured 51, so for very long prompts it falls short of the measured wait. These times were taken with the card mostly free; other requests running beside a long prompt lengthen them, as the section on running the model yourself shows. The first wait is paid once per document, provided the next questions can reuse the reading.&lt;/p&gt;

&lt;h2&gt;
  
  
  Later questions reuse what the server has read
&lt;/h2&gt;

&lt;p&gt;The server keeps a prompt cache, the internal state of a prompt it has already read, and a next request that begins with the same text skips reading that part again. Later questions about the same document came back in 0.6 to 1.0 seconds at about 130,000 tokens and in 1.1 to 1.6 seconds at about 260,000. To get this, put the fixed part first, the instructions and the document, and the question last, and send the document unchanged every time: the server reuses only a beginning that is identical to one it has read. In Blixild AI each customer's cache is kept apart, so only your own earlier requests speed up yours.&lt;/p&gt;

&lt;p&gt;For some documents the second question takes as long as the first: one of six long documents in our runs, 17 seconds at 131,000 tokens. The server marks how far it has read with a bookmark, which with this model can only stand at a multiple of 1,600 tokens, up to 1,600 tokens before the end of the request. In the other five, the bookmark fell inside the document, and the next question started from it. When it falls inside the first question instead, the bookmark covers words the second question does not share, so the server reads the whole document again. The questions after it were fast again. A short question after the document makes this rarer.&lt;/p&gt;

&lt;p&gt;The cache saves time, not money. Every question is billed for the whole document, so at $0.20 per million input tokens a question about a 260,000-token document costs about $0.05, and ten questions about $0.52. For one-off questions across many documents, a search that sends the model only the relevant passages costs less and answers sooner. How long the server keeps a document between questions depends on how busy the card is, and we have not measured it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running Qwen3.8-27B on your own H200
&lt;/h2&gt;

&lt;p&gt;The same measurements serve teams that run the model themselves. We serve it with &lt;a href="https://docs.vllm.ai" rel="noopener noreferrer"&gt;vLLM&lt;/a&gt;, an open-source program that runs models behind an OpenAI-compatible API, on one H200 NVL with 141 GB of memory, with the FP8 build and its cache stored in 8 bits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the model takes about 28 GiB, and 72 GiB set aside for the cache hold about 2 million tokens, seven to eight full-length requests at once;&lt;/li&gt;
&lt;li&gt;answers to eight requests at once come at about 1,100 tokens a second together, with short prompts;&lt;/li&gt;
&lt;li&gt;a long prompt is read in chunks, and every chunk holds up the other requests on the card.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;vLLM's setting &lt;code&gt;--long-prefill-token-threshold&lt;/code&gt; limits how much of a long prompt is read in each step while other requests run. At 1,024 tokens a step, the other requests kept 9 to 14 tokens a second beside a 254,000-token prompt, whose first token came after 63 seconds instead of 51. A lower value would favour the other requests further at the long prompt's cost, and we have not measured it. The figures hold for this card and this build; for another card, the calculator above gives a first estimate. How to put such a server behind keys and prices is the subject of our &lt;a href="https://blixild.com/self-hosted-llm-api-tech-stack.html" rel="noopener noreferrer"&gt;guide to a self-hosted LLM API&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to start with long documents
&lt;/h2&gt;

&lt;p&gt;A team that asks several questions about one set of documents can send the whole set in one request and expect the first answer in about a minute at the full length and the next ones in about a second. A team with one-off questions across many documents is better served by a search that picks the passages first. A team that runs the model itself should set the long-prompt limit before long documents arrive, so that one of them does not stall everyone else. The first steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign in at &lt;a href="https://ai.blixild.com" rel="noopener noreferrer"&gt;Blixild AI&lt;/a&gt;, where an API key and $1 of credit to start are ready at once.&lt;/li&gt;
&lt;li&gt;Send one of your documents and a question to &lt;code&gt;qwen3.8-27b&lt;/code&gt; with reasoning off, as in the example above.&lt;/li&gt;
&lt;li&gt;Ask the next questions with the document unchanged and in the same place, and keep the text after it short.&lt;/li&gt;
&lt;li&gt;Time the first and later answers on your own documents, and compare the cost per question with a search that sends only passages.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Qwen3.8 27B runs in Blixild AI on our H200 in Poland, at $0.20 per million input tokens and $1.50 per million output tokens. We set up and run a model at a customer's site or in their own cloud account as part of our &lt;a href="https://blixild.com/services.html#hosting" rel="noopener noreferrer"&gt;AI workload hosting&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Qwen (2026). Qwen3.8-27B-FP8, model card. &lt;a href="https://huggingface.co/Qwen/Qwen3.8-27B-FP8" rel="noopener noreferrer"&gt;https://huggingface.co/Qwen/Qwen3.8-27B-FP8&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;vLLM (2026). Automatic prefix caching. &lt;a href="https://docs.vllm.ai/en/stable/features/automatic_prefix_caching.html" rel="noopener noreferrer"&gt;https://docs.vllm.ai/en/stable/features/automatic_prefix_caching.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;vLLM (2026). Engine arguments. &lt;a href="https://docs.vllm.ai/en/stable/configuration/engine_args.html" rel="noopener noreferrer"&gt;https://docs.vllm.ai/en/stable/configuration/engine_args.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Prus, B. (1890). Lalka. Wolne Lektury. &lt;a href="https://wolnelektury.pl/katalog/lektura/lalka/" rel="noopener noreferrer"&gt;https://wolnelektury.pl/katalog/lektura/lalka/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Austen, J. (1813). Pride and Prejudice. Project Gutenberg eBook #1342. &lt;a href="https://www.gutenberg.org/ebooks/1342" rel="noopener noreferrer"&gt;https://www.gutenberg.org/ebooks/1342&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>performance</category>
      <category>rag</category>
    </item>
  </channel>
</rss>
