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
- Python
- JavaScript
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."}]
}'
from openai import OpenAI
client = OpenAI(base_url="https://api.tinyhop.eu/v1", api_key="sk-tiny-...")
answer = client.chat.completions.create(
model="deepseek-v4-1-flash-1017",
messages=[{"role": "user", "content": "Say hello in one short sentence."}],
)
print(answer.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.tinyhop.eu/v1",
apiKey: process.env.TINYHOP_KEY,
});
const answer = await client.chat.completions.create({
model: "deepseek-v4-1-flash-1017",
messages: [{ role: "user", content: "Say hello in one short sentence." }],
});
console.log(answer.choices[0].message.content);
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.
| Field | Type | Meaning |
|---|---|---|
model | string, required | A model id from the list. A name we kept for a renamed model resolves to it |
messages | array, required | Passed through. Images (image_url parts, data URLs included) are counted for the price bound and the capability check |
stream | bool | true answers as server-sent events |
max_tokens, max_completion_tokens | int | Either name works. Absent means the offer's default; above the offer's ceiling is a 400 max_tokens_too_large |
n | int | Above the service limit (16) is a 400 |
tools, tool_choice, response_format, temperature, top_p, stop, reasoning_effort, stream_options | any | Forwarded. 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]
- Python
- curl
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="")
curl -N https://api.tinyhop.eu/v1/chat/completions \
-H "Authorization: Bearer $TINYHOP_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek-v4-1-flash-1017", "stream": true,
"messages": [{"role": "user", "content": "Count to five."}]}'
-N turns curl's buffering off, or the tokens arrive in one block at the end and the stream is gone.
Headers
The body is the provider's; these headers are ours.
| Header | Meaning |
|---|---|
X-Tinyhop-Provider | Which provider answered, e.g. entrim |
X-Tinyhop-Model | Our model id, after alias resolution |
X-Tinyhop-Upstream | The model id that went on the wire - what the provider calls it |
X-Tinyhop-Alias | Present only when the request used an alias: the string you sent |
X-Tinyhop-Quantization | What the answer runs at: fp16, fp8, nvfp4, … |
X-Tinyhop-Cost | What the request cost in euro. On a streamed answer it arrives as a trailing header, after the last chunk |
Retry-After | On 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
| Status | Code | What to do |
|---|---|---|
| 400 | model_required | The body has no model |
| 400 | max_tokens_too_large | Above the ceiling of every offer for that model |
| 400 | context_length_exceeded | Prompt plus the requested answer does not fit |
| 400 | invalid_max_tokens, invalid_n, invalid_body | Wrong type or out of range |
| 401 | invalid_api_key | No key, or an unknown one |
| 402 | insufficient_credit | The reservation failed - top up. available is the number that matters |
| 403 | insufficient_scope | A manage key on /v1. Use an inference key |
| 404 | model_not_found | No offer your account can reach sells that model |
| 413 | body_too_large | Over the body limit |
| 429 | rate_limit_exceeded | Too many requests in flight; Retry-After says when |
| 503 | upstream_error | No provider could serve it. If you pinned one, the message names it |
| 503 | unavailable | The key could not be checked, or nothing can be priced right now |
Nothing is charged for a request that fails before it was answered.
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.