<?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: Gary Walkers</title>
    <description>The latest articles on DEV Community by Gary Walkers (@gary_walkers_fecd8f641755).</description>
    <link>https://dev.to/gary_walkers_fecd8f641755</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%2F4243687%2F741df241-3d37-47b5-8aaf-62b7d2fe3d11.png</url>
      <title>DEV Community: Gary Walkers</title>
      <link>https://dev.to/gary_walkers_fecd8f641755</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gary_walkers_fecd8f641755"/>
    <language>en</language>
    <item>
      <title>Prompting techniques and their token cost: system prompts, few-shot, chain-of-thought and injection</title>
      <dc:creator>Gary Walkers</dc:creator>
      <pubDate>Sat, 14 Nov 2026 00:17:31 +0000</pubDate>
      <link>https://dev.to/gary_walkers_fecd8f641755/prompting-techniques-and-their-token-cost-system-prompts-few-shot-chain-of-thought-and-injection-1nl7</link>
      <guid>https://dev.to/gary_walkers_fecd8f641755/prompting-techniques-and-their-token-cost-system-prompts-few-shot-chain-of-thought-and-injection-1nl7</guid>
      <description>&lt;p&gt;Every word in a prompt is billed, so each technique has a token cost. Here is what the vendors and papers say, with counts I measured using OpenAI's &lt;code&gt;o200k_base&lt;/code&gt; tokenizer.&lt;/p&gt;

&lt;h2&gt;
  
  
  System prompts are billed on every request
&lt;/h2&gt;

&lt;p&gt;My 225-word support-bot prompt is 275 tokens. At 1,000 requests a day that is 8.25M input tokens a month: $16.50 on Claude Sonnet 5.5 or GPT-6.1 Sol, $0.825 on Haiku 5.5. It will not cache on its own: Anthropic's minimum cacheable prompt for Sonnet 5.5 is 512 tokens and OpenAI's is 1,024 (&lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-caching" rel="noopener noreferrer"&gt;Anthropic prompt caching&lt;/a&gt;, &lt;a href="https://developers.openai.com/api/docs/guides/prompt-caching" rel="noopener noreferrer"&gt;OpenAI prompt caching&lt;/a&gt;). To count your own prompts, a &lt;a href="https://createchz.com/tokens/token-counter/" rel="noopener noreferrer"&gt;browser token counter&lt;/a&gt; works without uploading anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Few-shot: about 18 tokens per example
&lt;/h2&gt;

&lt;p&gt;In a five-category email classifier, zero-shot is 44 tokens and each example adds about 18, so 10 examples add 181 tokens to every request, or $36.20 per 100,000 requests on Sonnet 5.5. Anthropic recommends 3 to 5 diverse examples (&lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices" rel="noopener noreferrer"&gt;prompting best practices&lt;/a&gt;); the original result is &lt;a href="https://arxiv.org/abs/2005.14165" rel="noopener noreferrer"&gt;Brown et al. (2020)&lt;/a&gt;. Measure accuracy at 0, 3 and 5 examples before paying for more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chain-of-thought is paid as output
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/abs/2201.11903" rel="noopener noreferrer"&gt;Wei et al. (2022)&lt;/a&gt; and &lt;a href="https://arxiv.org/abs/2205.11916" rel="noopener noreferrer"&gt;Kojima et al. (2022)&lt;/a&gt; showed step-by-step reasoning helps 2022-era models: MultiArith went from 17.7% to 78.7% with "Let's think step by step" on text-davinci-002. Reasoning models now think internally, and &lt;a href="https://developers.openai.com/api/docs/guides/prompt-engineering" rel="noopener noreferrer"&gt;OpenAI's guide&lt;/a&gt; says to give them high-level goals. The visible reasoning is output tokens: 1 token for a direct answer versus 58 for a worked one in my example, or $0.01 versus $0.58 per 1,000 answers on Sonnet 5.5. Skip it for classification and extraction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt injection: design for it
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://genai.owasp.org/llmrisk/llm01-prompt-injection/" rel="noopener noreferrer"&gt;OWASP LLM01&lt;/a&gt; lists prompt injection as the top risk. Indirect injection, hidden instructions in a page or file the model reads, is the harder case, and OWASP says no fool-proof prevention is known. Limit privileges, validate output with deterministic code, require human approval for risky actions, label untrusted content, and test adversarially.&lt;/p&gt;

&lt;p&gt;A one-page summary of all of this is in this &lt;a href="https://createchz.com/prompting/prompt-engineering-guide/" rel="noopener noreferrer"&gt;prompt engineering guide&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>promptengineering</category>
    </item>
    <item>
      <title>Open weight is not open source: how to read an LLM licence, and how Claude, GPT-6 and Gemini 4 compare</title>
      <dc:creator>Gary Walkers</dc:creator>
      <pubDate>Sat, 14 Nov 2026 00:09:59 +0000</pubDate>
      <link>https://dev.to/gary_walkers_fecd8f641755/open-weight-is-not-open-source-how-to-read-an-llm-licence-and-how-claude-gpt-6-and-gemini-4-35h</link>
      <guid>https://dev.to/gary_walkers_fecd8f641755/open-weight-is-not-open-source-how-to-read-an-llm-licence-and-how-claude-gpt-6-and-gemini-4-35h</guid>
      <description>&lt;p&gt;"Which model should I use?" is easier once you know what a model is and what the labels mean. Prices below were verified against each provider's own pages on 13 November 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  What an LLM is
&lt;/h2&gt;

&lt;p&gt;An LLM turns text into tokens, passes them through a neural network and outputs a probability for every possible next token; generating a reply means choosing one, appending it and repeating. Four papers explain the field: &lt;a href="https://arxiv.org/abs/1706.03762" rel="noopener noreferrer"&gt;Attention Is All You Need&lt;/a&gt; (the Transformer, 2017), &lt;a href="https://arxiv.org/abs/2001.08361" rel="noopener noreferrer"&gt;Scaling Laws for Neural Language Models&lt;/a&gt; (2020), &lt;a href="https://arxiv.org/abs/2005.14165" rel="noopener noreferrer"&gt;Language Models are Few-Shot Learners&lt;/a&gt; (2020) and &lt;a href="https://arxiv.org/abs/2203.02155" rel="noopener noreferrer"&gt;InstructGPT&lt;/a&gt; (2022).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why attention shapes your bill
&lt;/h2&gt;

&lt;p&gt;The Transformer paper's own complexity comparison lists self-attention as costing operations proportional to the square of the sequence length per layer. That is one reason context windows have limits and long prompts are expensive to serve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Claude vs ChatGPT vs Gemini through their APIs
&lt;/h2&gt;

&lt;p&gt;USD per million tokens, input / output (tier placement is ours): flagship Claude Fable 5.2 $8 / $40, GPT-6 Astra $10 / $50, Gemini 4 Carbon $2 / $10; smallest tier Claude Haiku 5.5 and GPT-6 Luna both $0.10 / $0.50. Gemini 4 Carbon and Argon double on 1 December 2026. Current Claude models list a 1M-token window, GPT-6 1.05M, Gemini 4 1M (&lt;a href="https://platform.claude.com/docs/en/about-claude/models/overview" rel="noopener noreferrer"&gt;Anthropic&lt;/a&gt;, &lt;a href="https://developers.openai.com/api/docs/models" rel="noopener noreferrer"&gt;OpenAI&lt;/a&gt;, &lt;a href="https://aistudio.google.com/docs/models" rel="noopener noreferrer"&gt;Google&lt;/a&gt;). For 1,000 uncached chat turns of 1,500 input and 400 output tokens: Sonnet 5.5 $7.00, GPT-6.1 Terra $3.50, Gemini 4 Hydrogen $5.25. A side-by-side with caching and batch rules is in this &lt;a href="https://createchz.com/ai-models/claude-vs-chatgpt-vs-gemini/" rel="noopener noreferrer"&gt;Claude vs ChatGPT vs Gemini comparison&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open weight vs open source
&lt;/h2&gt;

&lt;p&gt;Open weight means the parameters are published. Under the Open Source Initiative's &lt;a href="https://opensource.org/ai/open-source-ai-definition" rel="noopener noreferrer"&gt;Open Source AI Definition 1.0&lt;/a&gt;, open source AI also needs sufficiently detailed training-data information and the complete training and running code, all under OSI-approved terms. Publisher examples: &lt;a href="https://openai.com/index/introducing-gpt-oss/" rel="noopener noreferrer"&gt;gpt-oss&lt;/a&gt; is Apache 2.0 and &lt;a href="https://github.com/openai/whisper" rel="noopener noreferrer"&gt;Whisper&lt;/a&gt; is MIT. Before building on a model, check the licence for weights and code, commercial limits, acceptable-use rules and hosting cost. A checklist is in this guide to &lt;a href="https://createchz.com/ai-models/open-source-vs-open-weight-llm/" rel="noopener noreferrer"&gt;open source vs open weight LLMs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>What an LLM API call really costs: the formula and four levers that move the bill</title>
      <dc:creator>Gary Walkers</dc:creator>
      <pubDate>Sat, 14 Nov 2026 00:09:31 +0000</pubDate>
      <link>https://dev.to/gary_walkers_fecd8f641755/what-an-llm-api-call-really-costs-the-formula-and-four-levers-that-move-the-bill-2748</link>
      <guid>https://dev.to/gary_walkers_fecd8f641755/what-an-llm-api-call-really-costs-the-formula-and-four-levers-that-move-the-bill-2748</guid>
      <description>&lt;p&gt;Prices are quoted per million tokens, but the bill depends on how many tokens you send, how many you get back, and which pricing rules apply. Figures below were checked against the providers' own pages on 13 November 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  The formula
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;cost = input_tokens / 1e6 * input_price + output_tokens / 1e6 * output_price&lt;/code&gt;, times requests per day, times 30. A support bot sending 1,500 input and 400 output tokens, 1,000 times a day, on Claude Sonnet 5.5 ($2 in, $10 out per million) costs &lt;strong&gt;$210.00 a month&lt;/strong&gt;; GPT-6.1 Sol lists the same prices (&lt;a href="https://platform.claude.com/docs/en/about-claude/pricing" rel="noopener noreferrer"&gt;Anthropic pricing&lt;/a&gt;, &lt;a href="https://developers.openai.com/api/docs/pricing" rel="noopener noreferrer"&gt;OpenAI pricing&lt;/a&gt;). You can reproduce it in an &lt;a href="https://createchz.com/ai-costs/llm-api-cost-calculator/" rel="noopener noreferrer"&gt;LLM API cost calculator&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lever 1: output costs more
&lt;/h2&gt;

&lt;p&gt;Across 65 models in our price table, output is 1.0x to 10.0x the input price, with a median of 5.0x. On Sonnet 5.5 a chat turn is about 21% output by tokens but 57% of the cost, so trimming replies usually saves more than trimming prompts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lever 2: caching
&lt;/h2&gt;

&lt;p&gt;Cached reads cost 0.1x the input price on most Claude models and on GPT-5.6 and later, and 0.05x on models such as Sonnet 5.5 and GPT-6.1 Sol; writing a cache entry costs 1.25x (&lt;a href="https://platform.claude.com/docs/en/build-with-claude/prompt-caching" rel="noopener noreferrer"&gt;Anthropic prompt caching&lt;/a&gt;). For a 10,000-token fixed prompt at 1,000 requests a day, our worked example falls from $690.00 to $120.72 a month. Minimum prompt lengths apply, so short system prompts will not cache.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lever 3: batch
&lt;/h2&gt;

&lt;p&gt;Anthropic, OpenAI and Google charge 50% less for jobs that can wait up to a day (&lt;a href="https://developers.openai.com/api/docs/guides/batch" rel="noopener noreferrer"&gt;OpenAI Batch API&lt;/a&gt;). The chatbot above falls from $210 to $105 a month.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lever 4: very long prompts
&lt;/h2&gt;

&lt;p&gt;OpenAI steps up above 272K input tokens, Gemini 3.1 Pro and Grok above 200K, Claude Haiku 5.5 above 100K. A 300K-token prompt costs about $0.61 on Sonnet 5.5 and $6.08 on GPT-6 Astra (our arithmetic from the published prices).&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare tiers, not brands
&lt;/h2&gt;

&lt;p&gt;On three reference workloads, Sonnet 5.5 and GPT-6.1 Sol cost the same; the small tier (Haiku 5.5 or GPT-6 Luna) costs $10.50, $9.00 and $8.52 a month, and flagships run 2 to 3 times the mid tier. Run the same 50 to 100 real prompts through each candidate and divide cost by passing answers. The full table is in this &lt;a href="https://createchz.com/ai-costs/openai-api-pricing/" rel="noopener noreferrer"&gt;OpenAI API pricing breakdown&lt;/a&gt; alongside the other providers.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>llm</category>
      <category>api</category>
    </item>
    <item>
      <title>Counting tokens exactly, and why the same sentence costs more in Hindi</title>
      <dc:creator>Gary Walkers</dc:creator>
      <pubDate>Sat, 14 Nov 2026 00:03:48 +0000</pubDate>
      <link>https://dev.to/gary_walkers_fecd8f641755/counting-tokens-exactly-and-why-the-same-sentence-costs-more-in-hindi-11ab</link>
      <guid>https://dev.to/gary_walkers_fecd8f641755/counting-tokens-exactly-and-why-the-same-sentence-costs-more-in-hindi-11ab</guid>
      <description>&lt;p&gt;Every LLM price, context limit and output cap is measured in tokens, so it pays to count them properly. Here is the short version, with the numbers I measured.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a token is
&lt;/h2&gt;

&lt;p&gt;A token is a chunk of text: a short word, part of a longer word, a few digits or a symbol. OpenAI's rule of thumb is about 4 characters or 0.75 words per token in English (&lt;a href="https://developers.openai.com/api/docs/concepts" rel="noopener noreferrer"&gt;OpenAI API concepts&lt;/a&gt;). With tiktoken's &lt;code&gt;o200k_base&lt;/code&gt;, "tokenization" is 2 tokens, "2026" splits into &lt;code&gt;202&lt;/code&gt; + &lt;code&gt;6&lt;/code&gt;, and the German compound "Straßenbahnhaltestelle" splits into 7. The vocabulary comes from byte-pair encoding, applied to subwords as in &lt;a href="https://arxiv.org/abs/1508.07909" rel="noopener noreferrer"&gt;Sennrich, Haddow and Birch (2015)&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Count exactly (OpenAI)
&lt;/h2&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;tiktoken&lt;/span&gt;
&lt;span class="n"&gt;enc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tiktoken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_encoding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"o200k_base"&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="nb"&gt;len&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="s2"&gt;"Hello world"&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;# 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/openai/tiktoken" rel="noopener noreferrer"&gt;tiktoken&lt;/a&gt; is OpenAI's open-source tokenizer. If you would rather not run code, this &lt;a href="https://createchz.com/tokens/token-counter/" rel="noopener noreferrer"&gt;browser token counter&lt;/a&gt; reproduces it; I compared it with tiktoken on more than 1,600 strings in both encodings and the ids matched every time. Nothing you paste is uploaded.&lt;/p&gt;

&lt;p&gt;Claude and Gemini do not publish downloadable tokenizers, so third-party counts for them are estimates; use each provider's token-counting endpoint for billing. Anthropic says its newer tokenizer (Claude 4.7 and later) produces roughly 30% more tokens for the same text than earlier Claude models (&lt;a href="https://platform.claude.com/docs/en/about-claude/models/overview" rel="noopener noreferrer"&gt;Anthropic models overview&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Words and tokens
&lt;/h2&gt;

&lt;p&gt;About 750 English words per 1,000 tokens. Code, JSON, long numbers and URLs split into many small tokens, so fewer words fit. A &lt;a href="https://createchz.com/tokens/tokens-to-words/" rel="noopener noreferrer"&gt;tokens to words converter&lt;/a&gt; gives the quick table from 1,000 to 1M tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Languages are not equal
&lt;/h2&gt;

&lt;p&gt;Two sentences in 15 languages with OpenAI's exact tokenizers: English 31 tokens, German 37, Russian 43, Hindi 47 on &lt;code&gt;o200k_base&lt;/code&gt; but 153 on the older &lt;code&gt;cl100k_base&lt;/code&gt;; Chinese used 25. It is a small sample with my own translations, so treat it as direction, not a benchmark. Count a sample of your own text before pricing a non-English workload.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context windows
&lt;/h2&gt;

&lt;p&gt;As of 13 November 2026, the current Claude 5 models list 1M tokens and 128K max output, GPT-6 lists 1.05M, and Gemini 4 and DeepSeek V4 list 1M, per each provider's model page. A bigger window is not free: you pay for every input token on every request.&lt;/p&gt;

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