ノート / 20

Six checks before you repoint a client at /v1

2026-11-19Modelry のノート

"OpenAI-compatible" is a claim about the request body and, often, nothing else. The endpoint will accept your messages array and return something that looks like a completion, then differ on the six things your code silently depends on: the model id you get back, where the usage block rides in a stream, whether cached tokens are reported, the shape of an error, whether pre-authorisation can reject a call the model would have afforded, and whether a retry re-bills text you already have. This article is a six-item check you can run in about a minute with curl, with the real responses from one endpoint beside each item.

### Why a checklist beats a compatibility claim

Compatibility is a spectrum and vendors sit at different points on it. The request side is nearly always right, because that is what is easiest to copy: messages, tools, max_tokens, stream. The response side is where implementations diverge, because each field is optional and each vendor's upstream reports slightly different things. Your SDK will not warn you — it types the response from OpenAI's schema and happily returns undefined for anything the endpoint omitted.

So verify in this order. Each step is one curl and one assertion.

### 1. The model ids are the endpoint's, not OpenAI's

GET /v1/models is the least expensive call you will ever make and it settles the catalogue question:

curl -sS https://api.tokenaimodels.com/v1/models | jq -r '.data[] | "\(.id) ctx=\(.context_length) out=\(.max_output_tokens)"'

Three ids come back on this endpoint — deepseek-chat, deepseek-chat-lite, deepseek-reasoner — each with its context and output ceiling in the same payload. If a vendor's docs list a dozen models and /v1/models returns four, believe the endpoint: a model that is documented but not served answers 503 no_channel, which looks like an outage and is actually a missing catalogue entry. Our own list lost a model exactly this way once, and it is now the reason the two are generated from one source file.

### 2. The model field echoes the upstream, not your request

Send deepseek-chat, read back:

{"id":"9fce9768-ad3e-4ea2-96dd-3b0f04b6eca8","object":"chat.completion","created":1795090256,
 "model":"deepseek-flash","choices":[{"index":0,"message":{"role":"assistant","content":"ok"},
 "logprobs":null,"finish_reason":"stop"}],
 "usage":{"prompt_tokens":9,"completion_tokens":1,"total_tokens":10,
 "prompt_tokens_details":{"cached_tokens":0},"prompt_cache_hit_tokens":0,"prompt_cache_miss_tokens":9},
 "system_fingerprint":"bc19ba97cbe016479903222bb1578db6"}

You asked for deepseek-chat; the response says deepseek-flash. That is the upstream id, reported honestly. It is useful — when routing changes, your logs show it without a support ticket — and it is also a trap for any code that keys a price table or a metric label off the response's model field. Key it off the id you sent. system_fingerprint is the upstream's, so treat it as a build marker for correlating incidents, not as a cache key.

x-request-id on the same response (req_d9d8e5d7-…) is the only handle that survives both hops, the platform and the provider. Log it on failure or you will have nothing to quote.

### 3. In a stream, the usage block is not where OpenAI puts it

This is the item that breaks the most parsers. With stream: true, OpenAI conventionally emits a final event whose choices array is empty and whose usage is populated. On this endpoint the count rides the frame that carries finish_reason: "stop", and choices is not empty:

data: {"id":"0d49af6b-…","object":"chat.completion.chunk","model":"deepseek-flash",
"choices":[{"index":0,"delta":{"content":""},"logprobs":null,"finish_reason":"stop"}],
"usage":{"prompt_tokens":9,"completion_tokens":1,"total_tokens":10,"prompt_tokens_details":{"cached_tokens":0},
"prompt_cache_hit_tokens":0,"prompt_cache_miss_tokens":9}}

A parser written as "skip events with empty choices, read usage from the skipped one" reports zero tokens on every request here and no error at all. Read usage from *any* frame that has it, and guard the empty-choices case separately, because both shapes exist across vendors. The event count is small and honest — four events for a two-character answer, then a literal data: [DONE].

### 4. Cached tokens are reported, twice, in two vocabularies

prompt_tokens_details.cached_tokens and prompt_cache_hit_tokens carry the same number here. The first is OpenAI's spelling, the second the upstream's. Both appear because neither client nor upstream should have to translate. If a compatible endpoint reports only prompt_tokens, you cannot audit a cache hit, and a cache that silently stops hitting is a cost increase with no error attached.

### 5. Errors are one envelope with the vendor's codes inside

Every failure returns {"error":{"message","type","code"}}, but the codes are the platform's. The four you will meet on day one, each reproduced here rather than described:

402 {"error":{"message":"Insufficient balance. Top up to continue.","type":"insufficient_quota","code":"insufficient_balance"}}
429 {"error":{"message":"Rate limit exceeded.","type":"rate_limit_error","code":"rate_limit_exceeded"}}
503 {"error":{"message":"Server busy. Retry shortly, or set stream=true to avoid buffering.","type":"server_error","code":"concurrency_limit"}}

402 is not retryable — the balance cannot cover the pre-authorisation, and retrying costs nothing but time. 429 carries retry-after in seconds and a fixed one-minute window, so honour the header instead of inventing a backoff. 503 concurrency_limit also carries retry-after: 2 and means the non-streaming in-flight cap is full, not that the model is down: stream: true avoids that particular queue entirely. Write your retry logic against these three codes and you will not need to guess.

### 6. Failover happens before the first token, and only where a second channel is configured

If a vendor says "failover", ask one question: can a retry duplicate text I already paid for? Here the answer is no, because a request is committed the moment bytes flow; only a request that produced nothing can move to another channel for the same model. Test it the only way that means anything — kill the network mid-stream and see whether the client gets a truncated 200 or an error. A truncated stream that quietly ends is worse than an error, because your retry logic will not fire.

### The one-minute version

Six commands, six assertions: catalogue from /v1/models, model echo from one call, stream framing with stream: true, cache fields on a repeated prompt, one deliberate 402 and one deliberate 429, and a mid-stream abort. Any endpoint that passes all six is worth migrating to. The full reference for this one is at /docs, the shortest path to a first call is /start, and if you are coming from a marketplace rather than from OpenAI, the comparison page sets out what changes beyond the base URL.

What each id does, its context and output ceiling, and what it is not for are set out on the deepseek-chat model page; the catalogue list is also where the three ids above are documented one by one.

See also: your first call in five minutes — the same checks as a runnable path.

Modelry は、1つの HTTP endpoint の背後で DeepSeek モデルを提供するプラットフォームを運営しています。前払いクレジットと税務は購入時に merchant of record が処理し、データ保持方針も文書で公開しています。$0.50 分のトライアルクレジットから始められます: キーを作成する。

すべてのノート

Six checks before you repoint a client at /v1 — Modelry