<?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: Kantro</title>
    <description>The latest articles on DEV Community by Kantro (@kantrodev).</description>
    <link>https://dev.to/kantrodev</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%2F4259450%2F9c45f6f9-db3c-42a1-86e6-064688d40bd9.png</url>
      <title>DEV Community: Kantro</title>
      <link>https://dev.to/kantrodev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kantrodev"/>
    <language>en</language>
    <item>
      <title>Probing native protocol error shapes on /v1/messages and /v1/responses</title>
      <dc:creator>Kantro</dc:creator>
      <pubDate>Mon, 23 Nov 2026 00:28:56 +0000</pubDate>
      <link>https://dev.to/kantrodev/probing-native-protocol-error-shapes-on-v1messages-and-v1responses-2a8l</link>
      <guid>https://dev.to/kantrodev/probing-native-protocol-error-shapes-on-v1messages-and-v1responses-2a8l</guid>
      <description>&lt;p&gt;Most LLM proxies advertise "OpenAI-compatible" endpoints and stop at &lt;code&gt;/v1/chat/completions&lt;/code&gt;. That works fine for a single chat call, then breaks the moment you point Claude Code or the Codex CLI at the proxy. Claude Code expects Anthropic's &lt;code&gt;/v1/messages&lt;/code&gt; and &lt;code&gt;/v1/messages/count_tokens&lt;/code&gt; shapes (including &lt;code&gt;type: "error"&lt;/code&gt; envelopes on 401s), and newer OpenAI clients call &lt;code&gt;/v1/responses&lt;/code&gt; and &lt;code&gt;/v1/responses/compact&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On &lt;a href="https://kantro.dev" rel="noopener noreferrer"&gt;Kantro&lt;/a&gt;, we kept the native endpoints separate instead of translating everything through a single schema. I wanted to verify whether unauthenticated error envelopes and route coverage actually stay native on the live edge, so I probed the four less-common endpoints directly against &lt;code&gt;kantro.dev&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;&lt;span class="k"&gt;for&lt;/span&gt; ep &lt;span class="k"&gt;in&lt;/span&gt; /v1/messages /v1/messages/count_tokens /v1/responses /v1/responses/compact&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== $ep ==="&lt;/span&gt;
  curl -sS -w &lt;span class="s2"&gt;"\nHTTP:%{http_code}\n"&lt;/span&gt; -X POST &lt;span class="s2"&gt;"https://kantro.dev$ep"&lt;/span&gt; \
    -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; -d &lt;span class="s1"&gt;'{}'&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what came back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== /v1/messages ===
{"type":"error","error":{"type":"authentication_error","message":"Invalid Kantro API key. Check your Bearer token or generate a key: https://kantro.dev/app/keys"}}
HTTP:401

=== /v1/messages/count_tokens ===
{"type":"error","error":{"type":"authentication_error","message":"Invalid Kantro API key. Check your Bearer token or generate a key: https://kantro.dev/app/keys"}}
HTTP:401

=== /v1/responses ===
{"error":{"message":"Invalid Kantro API key. Check your Bearer token or generate a key: https://kantro.dev/app/keys","type":"invalid_request_error","param":null,"code":"invalid_api_key"}}
HTTP:401

=== /v1/responses/compact ===
{"error":{"message":"Invalid Kantro API key. Check your Bearer token or generate a key: https://kantro.dev/app/keys","type":"invalid_request_error","param":null,"code":"invalid_api_key"}}
HTTP:401
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both Anthropic paths return Anthropic's &lt;code&gt;authentication_error&lt;/code&gt; wrapper, while both OpenAI paths return OpenAI's &lt;code&gt;invalid_request_error&lt;/code&gt; shape with &lt;code&gt;param&lt;/code&gt; and &lt;code&gt;code&lt;/code&gt;. That matters because official SDKs parse the error envelope differently before they even reach your retry logic. If a gateway returns an OpenAI error JSON on &lt;code&gt;/v1/messages&lt;/code&gt;, the Anthropic SDK's error parser falls back to an untyped error.&lt;/p&gt;

&lt;p&gt;Checking &lt;a href="https://kantro.dev/openapi.json" rel="noopener noreferrer"&gt;the OpenAPI spec&lt;/a&gt; also turned up &lt;code&gt;/v1/key&lt;/code&gt;, &lt;code&gt;/v1/keys&lt;/code&gt;, and &lt;code&gt;/v1/keys/{hash}&lt;/code&gt; alongside &lt;code&gt;/v1/models&lt;/code&gt; for inspecting per-key spend limits and rotating keys programmatically. On the CLI side, &lt;code&gt;npx kantro-setup&lt;/code&gt; writes keys to &lt;code&gt;~/.config/kantro/key&lt;/code&gt; (or reads &lt;code&gt;KANTRO_API_KEY&lt;/code&gt;) and prints file diffs before editing local tool configs instead of dropping keys into a repo &lt;code&gt;.env&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This only checks the unauthenticated 401 envelope and documented route surface. I did not run a streaming SSE diff against upstream Anthropic or OpenAI in this pass, so header and chunk parity on 200 responses still needs a keyed run to verify directly.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
