Skip to main content

Chat completions

POST /v1/chat/completions is the OpenAI endpoint, unchanged on the wire. If you already have a client, point it at https://api.tinyhop.eu/v1 and it works: same request body, same answer, same streaming format.

curl https://api.tinyhop.eu/v1/chat/completions \
-H "Authorization: Bearer $TINYHOP_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-1-flash-1017",
"messages": [{"role": "user", "content": "Say hello in one short sentence."}]
}'

The answer is the provider's own body, untouched:

{
"id": "chatcmpl-9xKq...",
"object": "chat.completion",
"created": 1732271400,
"model": "deepseek-v4-1-flash-1017",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help you today?" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 21, "completion_tokens": 12, "total_tokens": 33 }
}

model in the answer is what we actually called, which is the model your alias resolved to. If you send a concrete slug, it is the slug you sent.

What we read​

Everything else is forwarded unchanged - a field we do not understand is the provider's business, and a provider that refuses it answers with its own error, in the same shape.

FieldTypeMeaning
modelstring, requiredA model id from the list. A name we kept for a renamed model resolves to it
messagesarray, requiredPassed through. Images (image_url parts, data URLs included) are counted for the price bound and the capability check
streambooltrue answers as server-sent events
max_tokens, max_completion_tokensintEither name works. Absent means the offer's default; above the offer's ceiling is a 400 max_tokens_too_large
nintAbove the service limit (16) is a 400
tools, tool_choice, response_format, temperature, top_p, stop, reasoning_effort, stream_optionsanyForwarded. Whether a model supports one is the model's business, not ours

Images, tool calling and structured output work the way they do on the OpenAI API, but only at the models that publish the capability - GET /v1/models says which, per model.

Streaming​

"stream": true answers with server-sent events, one chunk per line, ending with data: [DONE]:

data: {"id":"chatcmpl-9xKq...","choices":[{"index":0,"delta":{"role":"assistant","content":""}}]}

data: {"id":"chatcmpl-9xKq...","choices":[{"index":0,"delta":{"content":"Hello"}}]}

data: {"id":"chatcmpl-9xKq...","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":"stop"}]}

data: [DONE]
stream = client.chat.completions.create(
model="deepseek-v4-1-flash-1017",
messages=[{"role": "user", "content": "Count to five."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")

Headers​

The body is the provider's; these headers are ours.

HeaderMeaning
X-Tinyhop-ProviderWhich provider answered, e.g. entrim
X-Tinyhop-ModelOur model id, after alias resolution
X-Tinyhop-UpstreamThe model id that went on the wire - what the provider calls it
X-Tinyhop-AliasPresent only when the request used an alias: the string you sent
X-Tinyhop-QuantizationWhat the answer runs at: fp16, fp8, nvfp4, …
X-Tinyhop-CostWhat the request cost in euro. On a streamed answer it arrives as a trailing header, after the last chunk
Retry-AfterOn 429, seconds until a slot frees

X-Tinyhop-Cost is the useful one for a dashboard of your own: it is what was written to the ledger, not an estimate from the token counts.

The model list​

curl https://api.tinyhop.eu/v1/models -H "Authorization: Bearer $TINYHOP_KEY"
{
"object": "list",
"data": [
{
"id": "glm-5-3",
"object": "model",
"owned_by": "tinyhop",
"context_window": 1000000,
"max_output_tokens": 131072,
"capabilities": { "tool_calling": true, "image_input": false, "reasoning": true }
}
]
}

The list is what your account can reach right now, and the numbers are the envelope every offer behind the model holds

  • not one provider's opinion. A model that no provider can serve you at the moment (retired, switched off, or not priced) is not in the list at all, so the list and the request path never disagree.

An alias appears as its own id next to the model it points at. context_window and max_output_tokens are absent on an alias: they belong to the model it resolves to.

Errors​

StatusCodeWhat to do
400model_requiredThe body has no model
400max_tokens_too_largeAbove the ceiling of every offer for that model
400context_length_exceededPrompt plus the requested answer does not fit
400invalid_max_tokens, invalid_n, invalid_bodyWrong type or out of range
401invalid_api_keyNo key, or an unknown one
402insufficient_creditThe reservation failed - top up. available is the number that matters
403insufficient_scopeA manage key on /v1. Use an inference key
404model_not_foundNo offer your account can reach sells that model
413body_too_largeOver the body limit
429rate_limit_exceededToo many requests in flight; Retry-After says when
503upstream_errorNo provider could serve it. If you pinned one, the message names it
503unavailableThe key could not be checked, or nothing can be priced right now

Nothing is charged for a request that fails before it was answered.

Pinned providers fail loudly

If you pinned a model to one provider (static routing, see the Management API) and that provider is out, the answer is a 503 naming it - not a silent reroute. Tick failover on the routing if you would rather have an answer from somewhere else.