cd /news/large-language-models/probing-native-protocol-error-shapes… · home › topics › large-language-models › article
[ARTICLE · art-174396] src=dev.to ↗ pub= topic=large-language-models verified=true sentiment=· neutral

Probing native protocol error shapes on /v1/messages and /v1/responses

A developer at Kantro probed the gateway's four less-common native endpoints — /v1/messages, /v1/messages/count_tokens, /v1/responses and /v1/responses/compact — and found each returns its provider's native 401 error envelope rather than a translated schema. The Anthropic paths return type: "error" with authentication_error, while the OpenAI paths return invalid_request_error with param and code fields, which the developer notes matters because official SDKs parse error envelopes differently before retry logic runs. The check covered only unauthenticated 401s and the documented route surface; streaming SSE parity on 200 responses was not tested.

recommendation

Preserve each provider's native error envelope on its own routes and curl the unauthenticated 401s of /v1/messages and /v1/responses to confirm SDKs parse them correctly.

more in playbook: Running AI in production
by read2 min views1 publishedNov 23, 2026

Most LLM proxies advertise "OpenAI-compatible" endpoints and stop at /v1/chat/completions. 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 /v1/messages and /v1/messages/count_tokens shapes (including type: "error" envelopes on 401s), and newer OpenAI clients call /v1/responses and /v1/responses/compact.

On Kantro, 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 kantro.dev:

for ep in /v1/messages /v1/messages/count_tokens /v1/responses /v1/responses/compact; do
  echo "=== $ep ==="
  curl -sS -w "\nHTTP:%{http_code}\n" -X POST "https://kantro.dev$ep" \
    -H "Content-Type: application/json" -d '{}'
done

Here is what came back:

=== /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

Both Anthropic paths return Anthropic's authentication_error wrapper, while both OpenAI paths return OpenAI's invalid_request_error shape with param and code. 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 /v1/messages, the Anthropic SDK's error parser falls back to an untyped error.

Checking the OpenAPI spec also turned up /v1/key, /v1/keys, and /v1/keys/{hash} alongside /v1/models for inspecting per-key spend limits and rotating keys programmatically. On the CLI side, npx kantro-setup writes keys to ~/.config/kantro/key (or reads KANTRO_API_KEY) and prints file diffs before editing local tool configs instead of dropping keys into a repo .env.

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.

── more in #large-language-models 4 stories · sorted by recency
── more on @kantro 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/probing-native-proto…] indexed:0 read:2min 2026-11-23 · —