<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ModelSite]]></title><description><![CDATA[ModelSite]]></description><link>https://modelsite.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 07:30:34 GMT</lastBuildDate><atom:link href="https://modelsite.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Prompt caching explained: how cache-hit pricing cuts your LLM bill]]></title><description><![CDATA[Cache-read pricing cuts the input cost of repeated prompts. How the ratio works, how to structure prompts for hits, and how to read the counter.]]></description><link>https://modelsite.hashnode.dev/prompt-caching-explained-how-cache-hit-pricing-cuts-your-llm-bill</link><guid isPermaLink="true">https://modelsite.hashnode.dev/prompt-caching-explained-how-cache-hit-pricing-cuts-your-llm-bill</guid><category><![CDATA[llm]]></category><category><![CDATA[api]]></category><category><![CDATA[Python]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[ModelSite]]></dc:creator><pubDate>Wed, 11 Nov 2026 17:02:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6af203c71515ac0c2c2e2deb/4c725827-df14-41f9-874b-5f9a1d6aaeb3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>An agent loop sends the same long prefix on every call: the system prompt, the tool definitions, the reference documents pinned at the top, the conversation so far. On a long session that prefix can dwarf the actual question, and you pay input price for all of it again and again. When a provider matches a repeated prefix, it reuses the earlier work and bills those tokens at a lower <strong>cache read</strong> rate.</p>
<h2>The ratio is what matters</h2>
<p>Every model page in the ModelSite catalog lists the cache-read price next to the input price. The ratio between the two decides what caching is worth. If cache reads cost a few percent of the input price, a stable prefix saves far more than on a model priced at a quarter of it, so look at that ratio instead of the headline input price.</p>
<p>The table below is calculated live from those same prices. It compares the input cost of 1,000 requests that each carry a 100,000-token prompt: once with no cache hits, once with 90% of the prompt served from cache. Output tokens are left out, because caching only changes the input side.</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/etgnb59n9nk8gtjh2jwr.png" alt="Savings table: model, cache-read price as a share of input price, input cost of 1,000 requests with no cache hits, with 90% cache hits, and the resulting input saving." /></p>
<p><em>Input cost of 1,000 requests × 100,000-token prompt each, at a 90% cache-hit rate, calculated from live catalog prices on 2026-11-12.</em></p>
<p>Prices move, so treat any screenshot as dated. The model pages — for example <a href="https://modelsite.ai/en/models/deepseek-v4.1-flash-1017/?utm_source=hashnode&amp;utm_campaign=prompt-caching-cache-hit-pricing-explained">deepseek-v4.1-flash-1017</a> and <a href="https://modelsite.ai/en/models/glm-5.3/?utm_source=hashnode&amp;utm_campaign=prompt-caching-cache-hit-pricing-explained">glm-5.3</a> — always show the current numbers.</p>
<h2>How to structure a prompt for cache hits</h2>
<ul>
<li>Put the stable parts first: the system prompt, tool definitions and reference material, before anything that varies.</li>
<li>Put the volatile parts last: the latest user message, timestamps, request IDs. A timestamp near the top invalidates the whole prefix on every call.</li>
<li>Keep the prefix byte-identical between calls. Providers generally match on an exact prefix, so even reordering the tool list can cost you the hit.</li>
<li>Send follow-up requests soon after the first. Caches expire, and the lifetime depends on the provider.</li>
<li>Stay on one model for a conversation. A cache belongs to a single model.</li>
</ul>
<h2>How to check that it is working</h2>
<p>The response reports what was served from cache. In the OpenAI response format the field is <code>usage.prompt_tokens_details.cached_tokens</code>; Anthropic's format uses <code>usage.cache_read_input_tokens</code>; DeepSeek adds <code>prompt_cache_hit_tokens</code>, which passes through unchanged. If the counter stays at zero on a prefix you deliberately repeat, something in that prefix changes between calls.</p>
<pre><code class="language-python">import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MODELSITE_API_KEY"],
    base_url="https://api.modelsite.ai/v1",
)

messages = [
    {"role": "system", "content": LONG_STABLE_PREFIX},  # identical every call
    {"role": "user", "content": "Summarize the third reference document."},  # varies every call
]
resp = client.chat.completions.create(model="glm-5.3", messages=messages)

details = resp.usage.prompt_tokens_details
cached = details.cached_tokens if details else 0
print(f"{cached} of {resp.usage.prompt_tokens} prompt tokens came from cache")
</code></pre>
<p>Run it twice with the same long prompt; on most providers the second call reports most of the prefix as cached. DeepSeek builds its disk cache in the background, so the hit can take another call to show up. The example uses the official <a href="https://github.com/openai/openai-python">OpenAI Python SDK</a> against an OpenAI-compatible endpoint, so the same check works on any OpenAI-compatible provider that reports cache hits. Provider fine print, including cache expiry, lives in the docs: <a href="https://developers.openai.com/api/docs/guides/prompt-caching">OpenAI's prompt caching guide</a>, <a href="https://platform.claude.com/docs/en/build-with-claude/prompt-caching">Anthropic's prompt caching page</a>, and <a href="https://api-docs.deepseek.com/guides/kv_cache/">DeepSeek's context caching notes</a>. ModelSite's <a href="https://docs.modelsite.ai/en/docs/chat/anthropic?utm_source=hashnode&amp;utm_campaign=prompt-caching-cache-hit-pricing-explained">Anthropic-compatible endpoint</a> reports the same <code>cache_read_input_tokens</code> field.</p>
<h2>Worth knowing</h2>
<ul>
<li>Cached tokens are billed at the cache-read rate <strong>instead of</strong> the input rate, not on top of it.</li>
<li>Not every model reports cache hits, and a few price cache writes separately. The model page shows the full breakdown.</li>
<li>Prefixes below a minimum length never cache at all. The threshold is provider- and model-specific: 1,024 tokens on OpenAI (GPT-5.6 and later; earlier models vary by request settings) and 512 to 4,096 tokens on Anthropic depending on the model. A short test prefix reports zero by design.</li>
<li>Cache prices and off-peak windows change. The table above was calculated from the live catalog on 2026-11-12; treat it as a snapshot, not the current price.</li>
</ul>
<p><em>Originally published on the <a href="https://modelsite.ai/en/blog/prompt-caching-cache-hit-pricing-explained/?utm_source=hashnode&amp;utm_campaign=prompt-caching-cache-hit-pricing-explained">ModelSite blog</a> on 2026-10-22.</em></p>
]]></content:encoded></item><item><title><![CDATA[Call DeepSeek, Qwen and GLM with one OpenAI-compatible API key]]></title><description><![CDATA[Call DeepSeek, Qwen and GLM with one OpenAI-compatible endpoint and one key. curl and Python SDK examples, live prices on each model page.]]></description><link>https://modelsite.hashnode.dev/call-deepseek-qwen-and-glm-with-one-openai-compatible-api-key</link><guid isPermaLink="true">https://modelsite.hashnode.dev/call-deepseek-qwen-and-glm-with-one-openai-compatible-api-key</guid><category><![CDATA[llm]]></category><category><![CDATA[api]]></category><category><![CDATA[Python]]></category><category><![CDATA[openai]]></category><category><![CDATA[Deepseek]]></category><dc:creator><![CDATA[ModelSite]]></dc:creator><pubDate>Tue, 10 Nov 2026 03:18:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6af203c71515ac0c2c2e2deb/08d538bb-9c57-4588-8b3f-6456b0edbb59.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Each model vendor usually has its own console, its own billing and its own key. Running DeepSeek, Qwen and GLM on the same task means juggling all of them: separate sign-ups, separate billing, and rate-limit rules that never match.</p>
<h2>One endpoint, one key</h2>
<p>ModelSite exposes an OpenAI-compatible endpoint at <code>https://api.modelsite.ai/v1</code>. You authenticate with a single key (it starts with <code>sk-ms-</code>) in the <code>Authorization: Bearer</code> header and choose the model with the <code>model</code> field. Nothing else about the request changes.</p>
<h2>Try it with curl</h2>
<pre><code class="language-bash">curl https://api.modelsite.ai/v1/chat/completions \
  -H "Authorization: Bearer $MODELSITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-1017",
    "messages": [{"role": "user", "content": "Explain TCP slow start in two sentences."}]
  }'
</code></pre>
<h2>Switch models by changing one string</h2>
<p>With the official OpenAI Python SDK, point <code>base_url</code> at ModelSite and loop over model names. The request and response format is the same for every model, so parsing and error handling stay as they are.</p>
<pre><code class="language-python">import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MODELSITE_API_KEY"],
    base_url="https://api.modelsite.ai/v1",
)

for model in ["deepseek-v4.1-flash-1017", "qwen3.7-max", "glm-5.3-flash"]:
    resp = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Explain TCP slow start in two sentences."}],
    )
    print(model, "-&gt;", resp.choices[0].message.content)
</code></pre>
<h2>What each of these costs</h2>
<p>Prices are per million tokens and change over time, so we don't paste them here. Open a model page for the live price, context length, cache pricing and time-window discounts:</p>
<ul>
<li><a href="https://modelsite.ai/en/models/deepseek-v4.1-flash-1017?utm_source=hashnode&amp;utm_campaign=one-api-key-deepseek-qwen-glm">deepseek-v4.1-flash-1017</a></li>
<li><a href="https://modelsite.ai/en/models/qwen3.7-max?utm_source=hashnode&amp;utm_campaign=one-api-key-deepseek-qwen-glm">qwen3.7-max</a></li>
<li><a href="https://modelsite.ai/en/models/glm-5.3-flash?utm_source=hashnode&amp;utm_campaign=one-api-key-deepseek-qwen-glm">glm-5.3-flash</a></li>
</ul>
<h2>Already using the Anthropic SDK?</h2>
<p>ModelSite also exposes an Anthropic-compatible endpoint (same keys, different base URL). The <a href="https://docs.modelsite.ai/en/docs/sdk?utm_source=hashnode&amp;utm_campaign=one-api-key-deepseek-qwen-glm">SDK guide</a> lists the base URL and the authentication difference.</p>
<h2>Calling each vendor directly</h2>
<p>Prefer calling each vendor directly? Their docs are the source of truth: <a href="https://api-docs.deepseek.com/">DeepSeek</a>, <a href="https://www.alibabacloud.com/help/en/model-studio/">Qwen via Alibaba Cloud</a>, <a href="https://docs.bigmodel.cn/">GLM by Zhipu</a>. You trade one key for three, which is the whole trade-off this article is about. For the client side, the OpenAI <a href="https://github.com/openai/openai-python">Python SDK</a> documents <code>base_url</code> and the other options used above.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6af203c71515ac0c2c2e2deb/e3fc28b4-c46f-42ae-bedc-b01eb40d8421.png" alt="The model page lists both call paths side by side: one shared endpoint and key for every model, or the vendor's own API with a separate account." /></p>
<blockquote>
<p>Originally published on the <a href="https://modelsite.ai/en/blog/one-api-key-deepseek-qwen-glm?utm_source=hashnode&amp;utm_campaign=one-api-key-deepseek-qwen-glm">ModelSite blog</a>, 2026-10-22.</p>
</blockquote>
]]></content:encoded></item></channel></rss>