<?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: TTapi</title>
    <description>The latest articles on DEV Community by TTapi (@ttapi_relay).</description>
    <link>https://dev.to/ttapi_relay</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%2F4286188%2F74cc1146-1acb-461b-9e23-d7c63e6287ed.png</url>
      <title>DEV Community: TTapi</title>
      <link>https://dev.to/ttapi_relay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ttapi_relay"/>
    <language>en</language>
    <item>
      <title>TTFT vs total latency: why your relay benchmark lies to you</title>
      <dc:creator>TTapi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 13:30:07 +0000</pubDate>
      <link>https://dev.to/ttapi_relay/ttft-vs-total-latency-why-your-relay-benchmark-lies-to-you-306f</link>
      <guid>https://dev.to/ttapi_relay/ttft-vs-total-latency-why-your-relay-benchmark-lies-to-you-306f</guid>
      <description>&lt;p&gt;You benchmark a relay. It reports 400ms median. The agent still feels slow. Both numbers are correct — they measure different things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two different clocks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TTFT (time to first token)&lt;/strong&gt;: from request to the first byte of streamed output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Total latency&lt;/strong&gt;: from request to the last byte.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a short answer, they are close. For a 2000-token code generation they diverge by an order of magnitude. A relay with a great total latency can still have a bad TTFT, and TTFT is what a human perceives as "slow".&lt;/p&gt;

&lt;h2&gt;
  
  
  Why simple benchmarks mislead
&lt;/h2&gt;

&lt;p&gt;Hitting &lt;code&gt;/v1/models&lt;/code&gt; measures connection setup plus routing: TLS, auth, upstream selection. Useful for availability, useless for perceived speed.&lt;/p&gt;

&lt;p&gt;Hitting &lt;code&gt;/chat/completions&lt;/code&gt; without &lt;code&gt;stream: true&lt;/code&gt; measures total latency only. You get one number that hides everything that matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measuring TTFT properly
&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;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ttft&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"count to 50"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&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="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"stream"&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="s2"&gt;"max_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"messages"&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="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prompt&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;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;body&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 "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content-type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;t0&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;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;r&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;raw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&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;"data:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;first&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;perf_counter&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;t0&lt;/span&gt;
            &lt;span class="c1"&gt;# keep reading to also get total&lt;/span&gt;
    &lt;span class="n"&gt;total&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;perf_counter&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;t0&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;first&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="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it three times. Typical shapes:&lt;/p&gt;

&lt;p&gt;| TTFT | Total | Reading |&lt;br&gt;
|&lt;/p&gt;

</description>
      <category>ai</category>
      <category>performance</category>
      <category>api</category>
      <category>python</category>
    </item>
    <item>
      <title>OpenAI-compatible base URL: the three things that actually have to match</title>
      <dc:creator>TTapi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 13:29:05 +0000</pubDate>
      <link>https://dev.to/ttapi_relay/openai-compatible-base-url-the-three-things-that-actually-have-to-match-n9k</link>
      <guid>https://dev.to/ttapi_relay/openai-compatible-base-url-the-three-things-that-actually-have-to-match-n9k</guid>
      <description>&lt;p&gt;"OpenAI-compatible" gets used loosely. When a relay claims it, only three things have to be true — and knowing which three saves you from debugging the wrong layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Path shape
&lt;/h2&gt;

&lt;p&gt;The client appends its own path to whatever base you give it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;
&lt;span class="no"&gt;GET&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So if the SDK expects &lt;code&gt;base_url = "https://host/v1"&lt;/code&gt;, the relay must serve &lt;code&gt;/v1/chat/completions&lt;/code&gt;. If the SDK expects the base without &lt;code&gt;/v1&lt;/code&gt;, the relay must serve &lt;code&gt;/chat/completions&lt;/code&gt;. Both conventions exist in the wild; the relay has to match the client, not the other way around.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Auth header
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the whole contract. A relay that also accepts &lt;code&gt;x-api-key&lt;/code&gt; is being generous, not compliant. If your client sends Bearer and gets 401, the key is wrong — not the header name.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Response envelope
&lt;/h2&gt;

&lt;p&gt;The non-streaming response must have &lt;code&gt;choices[0].message.content&lt;/code&gt; and &lt;code&gt;usage.prompt_tokens / completion_tokens&lt;/code&gt;. Streaming must emit &lt;code&gt;data: {json}&lt;/code&gt; lines terminated by &lt;code&gt;data: [DONE]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Most "compatible" servers get this right for chat but drift on streaming — especially the terminator. A client that hangs waiting for &lt;code&gt;[DONE]&lt;/code&gt; is not a client bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does NOT have to match
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Error body format.&lt;/strong&gt; Clients mostly branch on the status code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model names.&lt;/strong&gt; They are provider-specific strings; what matters is that &lt;code&gt;/models&lt;/code&gt; lists the same names you pass to &lt;code&gt;chat/completions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token counting exactness.&lt;/strong&gt; Close enough is fine; exactness is a billing concern, not a compatibility one.&lt;/li&gt;
&lt;/ul&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://your-relay.example/v1/models -H &lt;span class="s2"&gt;"Authorization: Bearer $KEY"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; head -c 200
curl -s https://your-relay.example/v1/chat/completions \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $KEY"&lt;/span&gt; -H &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"&amp;lt;model&amp;gt;","messages":[{"role":"user","content":"hi"}],"max_tokens":8}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two 200s with sane bodies means compatibility is fine and any remaining problem is client config or concurrency.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>openai</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Claude Code through a relay: the 401 / 403 / 404 map</title>
      <dc:creator>TTapi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 12:57:49 +0000</pubDate>
      <link>https://dev.to/ttapi_relay/claude-code-through-a-relay-the-401-403-404-map-e0g</link>
      <guid>https://dev.to/ttapi_relay/claude-code-through-a-relay-the-401-403-404-map-e0g</guid>
      <description>&lt;p&gt;Claude Code fails in three ways when you point it at a relay, and each one points at a different layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  404 — the base URL is wrong
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Code appends &lt;code&gt;/v1/messages&lt;/code&gt; itself. If your base already ends in &lt;code&gt;/v1&lt;/code&gt;, you get the doubled path.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://your-relay.example"&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sk-..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the opposite of OpenAI-compatible clients, where the base &lt;strong&gt;must&lt;/strong&gt; include &lt;code&gt;/v1&lt;/code&gt;. People switch between Claude Code and Codex and carry the wrong convention across. That single suffix is behind most 404s I have seen.&lt;/p&gt;

&lt;h2&gt;
  
  
  401 — the auth header, not your balance
&lt;/h2&gt;

&lt;p&gt;Anthropic wire format uses &lt;code&gt;x-api-key&lt;/code&gt;. OpenAI uses &lt;code&gt;Authorization: Bearer&lt;/code&gt;. A relay that accepts both still expects the matching header per protocol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s https://your-relay.example/v1/messages \
  -H &lt;span class="s2"&gt;"x-api-key: $ANTHROPIC_AUTH_TOKEN"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"anthropic-version: 2023-06-01"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"&amp;lt;model&amp;gt;","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If that works but Claude Code does not, the header name is the difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  403 — the model is not enabled
&lt;/h2&gt;

&lt;p&gt;Not network, not key format. The account or key lacks that model. Verify against what the relay reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  The order to debug in
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;curl /v1/models&lt;/code&gt; — is the endpoint reachable with this key?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;curl /v1/messages&lt;/code&gt; — does the Anthropic path work?&lt;/li&gt;
&lt;li&gt;Claude Code — only now look at the client.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two minutes in this order. The reverse order (start with the client, change settings randomly) takes an afternoon and ends with a working config nobody understands.&lt;/p&gt;

&lt;h2&gt;
  
  
  One thing nobody mentions
&lt;/h2&gt;

&lt;p&gt;Claude Code fires several requests in parallel. A relay that handles single requests fine can still throw 429 under real usage. If curl works but Claude Code shows rate errors, that is concurrency, not configuration.&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>api</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Benchmark any LLM API relay in 30 seconds with one Python file</title>
      <dc:creator>TTapi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 12:57:43 +0000</pubDate>
      <link>https://dev.to/ttapi_relay/benchmark-any-llm-api-relay-in-30-seconds-with-one-python-file-4177</link>
      <guid>https://dev.to/ttapi_relay/benchmark-any-llm-api-relay-in-30-seconds-with-one-python-file-4177</guid>
      <description>&lt;p&gt;Every "which relay is fastest" post I read is a snapshot someone took last month. Latency moves. Availability moves. You need your own number, taken now.&lt;/p&gt;

&lt;p&gt;One file, standard library only, no pip install, no API key needed for a connectivity check.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it measures
&lt;/h2&gt;

&lt;p&gt;Two things that actually decide whether your coding agent is usable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Does it respond at all&lt;/strong&gt; — status code per endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How long it takes&lt;/strong&gt; — median latency across N rounds, plus fastest and slowest.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 bench.py https://your-relay.example/v1 --key &lt;span class="nv"&gt;$RELAY_KEY&lt;/span&gt; --rounds 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

| endpoint                      | ok  | status | median | fastest | slowest |
|
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>api</category>
      <category>performance</category>
    </item>
    <item>
      <title>base_url with or without /v1: the 404 that wastes an afternoon</title>
      <dc:creator>TTapi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 10:56:25 +0000</pubDate>
      <link>https://dev.to/ttapi_relay/baseurl-with-or-without-v1-the-404-that-wastes-an-afternoon-j3g</link>
      <guid>https://dev.to/ttapi_relay/baseurl-with-or-without-v1-the-404-that-wastes-an-afternoon-j3g</guid>
      <description>&lt;p&gt;Two clients, same relay, opposite conventions. This costs people an afternoon more often than any other setup issue, so here's the whole thing in one place.&lt;/p&gt;

&lt;h2&gt;
  
  
  The table
&lt;/h2&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;Claude Code (Anthropic protocol)&lt;/th&gt;
&lt;th&gt;Codex / OpenAI-compatible&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Path the client calls&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/v1/messages&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/v1/chat/completions&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth header&lt;/td&gt;
&lt;td&gt;&lt;code&gt;x-api-key&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Authorization: Bearer&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;base_url&lt;/code&gt; should end with&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;nothing&lt;/strong&gt; (&lt;code&gt;https://host&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;&lt;code&gt;/v1&lt;/code&gt;&lt;/strong&gt; (&lt;code&gt;https://host/v1&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The client appends the path itself. Put &lt;code&gt;/v1&lt;/code&gt; in a base_url that already expects to append it and you get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. That's the bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working configs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Claude Code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://your-relay.example"&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sk-..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Codex / OpenAI-compatible:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OPENAI_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://your-relay.example/v1"&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sk-..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you switch clients often, generating these by hand is how typos get in. I wrote a small script that emits the right block per client and corrects the &lt;code&gt;/v1&lt;/code&gt; suffix automatically — it's on PyPI as &lt;code&gt;ttapi-relay-switch&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install ttapi-relay-switch
ttapi-relay-switch --client claude-code --base https://your-relay.example --key sk-...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verifying before you blame the client
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# OpenAI shape&lt;/span&gt;
curl -s https://your-relay.example/v1/models -H &lt;span class="s2"&gt;"Authorization: Bearer $OPENAI_API_KEY"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; head -c 200

&lt;span class="c"&gt;# Anthropic shape&lt;/span&gt;
curl -s https://your-relay.example/v1/messages \
  -H &lt;span class="s2"&gt;"x-api-key: $ANTHROPIC_AUTH_TOKEN"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"anthropic-version: 2023-06-01"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"&amp;lt;model&amp;gt;","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If curl returns a model list / a message object, the relay path is fine and the problem is in client config. If curl also fails, it's the endpoint or the key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Error map
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;404&lt;/strong&gt; — path duplication (&lt;code&gt;/v1/v1/...&lt;/code&gt;) or wrong base for the protocol.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;401&lt;/strong&gt; — key truncated, revoked, or wrong header name (&lt;code&gt;x-api-key&lt;/code&gt; vs &lt;code&gt;Authorization&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;403&lt;/strong&gt; — model not enabled on that account/key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;429&lt;/strong&gt; — concurrency cap; back off, don't retry in parallel.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Setup docs and a benchmark script: &lt;a href="https://kuku-momo.github.io/ai-relay/" rel="noopener noreferrer"&gt;kuku-momo.github.io/ai-relay&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>api</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to tell if an API relay is quietly rewriting your prompts</title>
      <dc:creator>TTapi</dc:creator>
      <pubDate>Sun, 06 Dec 2026 10:56:24 +0000</pubDate>
      <link>https://dev.to/ttapi_relay/how-to-tell-if-an-api-relay-is-quietly-rewriting-your-prompts-3o83</link>
      <guid>https://dev.to/ttapi_relay/how-to-tell-if-an-api-relay-is-quietly-rewriting-your-prompts-3o83</guid>
      <description>&lt;p&gt;Most "the model got dumber" reports aren't about the model. They're about the layer between you and the model.&lt;/p&gt;

&lt;p&gt;I've been debugging this on and off for a few months, and there are exactly three things that silently change a request on the way to the upstream API. None of them return an error.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;1. Prompt rewriting.&lt;/strong&gt; Your prompt is paraphrased into something "safer" before it reaches the model. The response reads fine; the constraints you set are gone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. System prompt substitution.&lt;/strong&gt; The operator's system prompt is replaced with the vendor's default. The model keeps its voice but loses your instructions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Fallback downgrade.&lt;/strong&gt; The request is routed to a cheaper model. No error, no header change — just a shallower answer.&lt;/p&gt;

&lt;p&gt;All three are invisible from the client side. You only notice that output quality drifted.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 3-step test that actually catches it
&lt;/h2&gt;

&lt;p&gt;The idea is to send something with a &lt;strong&gt;rigid, checkable structure&lt;/strong&gt; and see whether the structure survives.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s &lt;span class="s2"&gt;"$BASE_URL/chat/completions"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"&amp;lt;model&amp;gt;","messages":[{"role":"user","content":"Output only this JSON, no explanation: {\"alpha\":1,\"beta\":2}"}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then compare against a direct upstream call:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key names changed&lt;/strong&gt; → prompt was rewritten.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extra disclaimers appeared&lt;/strong&gt; → system prompt substituted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structure right, reasoning thin&lt;/strong&gt; → fallback model.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run it three times. Sampling gives you different wording each time, but the &lt;em&gt;structure&lt;/em&gt; should be stable. If the structure moves between runs, something upstream is doing non-deterministic editing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What "no rewrite" actually means
&lt;/h2&gt;

&lt;p&gt;The only configuration that holds up is: the prompt is forwarded to the upstream API unmodified, with no review step, no rewrite step, and no system-prompt injection.&lt;/p&gt;

&lt;p&gt;In practice you can't audit a vendor's internals — you can only observe. So keep the probe command around, run it whenever quality seems off, and switch routes when it fails. That's a five-minute check that saves a week of "is it me or them".&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Notes on the relay I use for this: &lt;a href="https://kuku-momo.github.io/pojia-cloud/" rel="noopener noreferrer"&gt;kuku-momo.github.io/pojia-cloud&lt;/a&gt;. The test above works against any OpenAI- or Anthropic-compatible endpoint — it doesn't require a specific vendor.&lt;/em&gt;&lt;/p&gt;

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