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

> Source: <https://dev.to/kantrodev/probing-native-protocol-error-shapes-on-v1messages-and-v1responses-2a8l>
> Published: 2026-11-23 00:28:56+00:00

**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 the playbook "Running AI in production": <https://wpnews.pro/playbooks/production-ops>

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](https://kantro.dev), 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](https://kantro.dev/openapi.json) 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.
