Chat completions
Send messages, get an answer back whole or as a stream, and read the response headers.
POST /v1/chat/completions follows OpenAI's chat completions API.
One answer
curl https://api.teepin.com/v1/chat/completions \
-H "Authorization: Bearer $TEEPIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "teepin/glm-5.3",
"messages": [
{"role": "system", "content": "Be brief."},
{"role": "user", "content": "What is TLS?"}
],
"max_tokens": 300,
"chat_template_kwargs": {"enable_thinking": false}
}'Request fields
| Field | Notes |
|---|---|
model | Required. An id from the model list. |
messages | Required, not empty. Roles system, user, assistant and tool. Content is a string or OpenAI content parts, for example {"type": "image_url", "image_url": {"url": "..."}}. |
max_tokens or max_completion_tokens | The answer's token budget. If both are sent, max_completion_tokens wins. |
stream, stream_options | Stream the answer. {"include_usage": true} adds token counts to the last chunk. |
temperature, top_p, top_k, min_p, seed, stop, n | Sampling. |
frequency_penalty, presence_penalty, repetition_penalty, logit_bias | Penalties and biases. |
logprobs, top_logprobs | Token log probabilities. |
tools, tool_choice, response_format | Tool calls and structured output, where the model supports them. |
user | Your own identifier for the end user. |
chat_template_kwargs | Template options, for example {"enable_thinking": false}. See Reasoning models. |
Any other field is ignored.
Streaming
With "stream": true the answer arrives as server-sent events: one data: {...} line per chat.completion.chunk, ending with data: [DONE].
curl -N https://api.teepin.com/v1/chat/completions \
-H "Authorization: Bearer $TEEPIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "teepin/glm-5.3",
"messages": [{"role": "user", "content": "Write a haiku about the sea."}],
"stream": true,
"stream_options": {"include_usage": true}
}'If the model fails part way through, the stream sends data: {"error": {...}} and closes without [DONE]. A stream that closes without [DONE] and without an error frame was cut off. The SDKs raise an error in both cases, so a partial answer is never mistaken for a whole one.
Response headers
| Header | Meaning |
|---|---|
X-Request-ID | Quote it when you contact support. |
X-Teepin-Attestation | For confidential models: verified, verified-older-release or not-verified. See Confidential models. |
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset | Your current window. See Rate limits. |
Billing
Each answer is billed by its input and output tokens at the model's prices, from your prepaid credit. An answer is billed once the model has written it, even if your client has gone. A request refused with an error is not billed. See Billing.