What you'll build
A working integration that calls glm-5.3 through hiapi's OpenAI-compatible Chat Completions API — a single request that returns a real completion, plus the one production gotcha that actually trips people up on this model: its reasoning tokens eat into your max_tokens budget.
Prerequisite: an hiapi API key. Grab one from the dashboard — it's a single sk-... string, and the same key works across every enabled model in your account, not just this one.
Every request and response below was run against the live API while writing this piece.
Minimal runnable example
glm-5.3 is a text model on the standard Chat Completions endpoint — not the async /v1/tasks flow hiapi uses for image/video/audio models. One request, one response, no polling.
curl https://api.hiapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-<your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3",
"messages": [
{"role": "user", "content": "Reply with exactly: OK"}
],
"max_tokens": 200
}'
Response (trimmed):
{
"id": "8be5f07603f0407c90734e8b4c2f02f0",
"object": "chat.completion",
"model": "glm-5.3",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "OK",
"reasoning_content": "The user wants me to reply with exactly \"OK\" ..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 17,
"completion_tokens": 35,
"total_tokens": 52,
"completion_tokens_details": { "reasoning_tokens": 32 }
}
}
Same call in Python, using only requests:
import requests
resp = requests.post(
"https://api.hiapi.ai/v1/chat/completions",
headers={"Authorization": "Bearer sk-<your-api-key>"},
json={
"model": "glm-5.3",
"messages": [
{"role": "user", "content": "Reply with exactly: OK"}
],
"max_tokens": 200,
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()
print(data["choices"][0]["message"]["content"])
print(data["usage"])
Because the shape is OpenAI-compatible, this also works unmodified with the official openai Python/JS SDKs — just point base_url at https://api.hiapi.ai/v1 and pass your hiapi key.
Production patterns
Reasoning tokens will eat a low max_tokens budget
glm-5.3 always thinks before it answers — every response carries a reasoning_content field alongside content, and there's no request flag to turn it off. That reasoning counts against max_tokens before the visible answer does. Set the budget too low and you'll get back content: null with finish_reason: "length", because the model spent its whole allowance thinking and never got to write the reply:
{
"choices": [{
"message": { "content": null, "reasoning_content": "The user has given a very simple instruction: \"" },
"finish_reason": "length"
}],
"usage": { "completion_tokens": 10, "completion_tokens_details": { "reasoning_tokens": 9 } }
}
Give even trivial prompts real headroom (200+ tokens is a safe floor) and always check finish_reason before trusting content — "length" means the answer was cut off, possibly before it started.
Streaming
Set "stream": true and read Server-Sent Events. Reasoning and answer text arrive as separate delta fields — delta.reasoning_content chunks first, then delta.content once the model starts the actual reply — and the stream ends with finish_reason: "stop" on the final chunk:
curl https://api.hiapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-<your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3",
"messages": [{"role": "user", "content": "Count to 3."}],
"max_tokens": 200,
"stream": true
}'
data: {"choices":[{"delta":{"role":"assistant","content":"","reasoning_content":null},"finish_reason":null}]}
data: {"choices":[{"delta":{"content":null,"reasoning_content":"The"},"finish_reason":null}]}
data: {"choices":[{"delta":{"content":"1, ","reasoning_content":null},"finish_reason":null}]}
data: {"choices":[{"delta":{"content":"2, 3.","reasoning_content":null},"finish_reason":null}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}]}
If you're streaming to a UI, route reasoning_content and content to different panes rather than concatenating them — they're not the same stream of text.
Tool calls
Function calling follows the standard OpenAI shape. Declare tools, and when the model decides to call one, finish_reason comes back as "tool_calls" with a populated tool_calls array (it still reasons first, so reasoning_content is present too):
{
"message": {
"role": "assistant",
"content": null,
"reasoning_content": "The user wants to know the weather in Paris. I have a tool available for that. Let me call it.",
"tool_calls": [{
"id": "call_12e21fe488f046bc9edb4488",
"type": "function",
"function": { "name": "get_weather", "arguments": "{\"city\": \"Paris\"}" }
}]
},
"finish_reason": "tool_calls"
}
Replay the assistant's tool_calls message plus a role: "tool" result message on the next turn, same as any OpenAI-compatible integration.
Error handling
An invalid or missing key returns HTTP 401 with a consistent error shape — check status before parsing choices:
{
"error": {
"code": "permission_denied",
"message": "This API key is invalid. Check that it is correct or use another API key and try again.",
"type": "hiapi_error"
}
}
Related resources
- glm-5.3 model page — capabilities and current availability
- hiapi pricing — current per-token rates
- API keys dashboard — create and manage keys
- How to Use kimi-k3 via the hiapi API — another Chat Completions text model on hiapi
- How to Use deepseek-v4.1-flash via the hiapi API — same integration pattern, different model
FAQ
Does glm-5.3 support streaming?
Yes — set "stream": true and read the SSE chunks. Reasoning and answer content stream as separate delta fields.
Why is content null in my response?
Almost always a max_tokens budget too small to cover both reasoning and the answer. Check finish_reason: "length" means the response was cut off before (or during) the real answer. Raise max_tokens.
Can I disable the reasoning step?
Not via a request parameter — glm-5.3 reasons before every response, and reasoning_content is always populated. Budget for it rather than trying to turn it off.
Does glm-5.3 support function/tool calling?
Yes, using the standard OpenAI tools / tool_calls shape, verified against the live endpoint.
Can I use the official OpenAI SDK instead of raw HTTP?
Yes. Point the SDK's base_url at https://api.hiapi.ai/v1 and use your hiapi sk-... key as the API key — no other changes needed.
How is glm-5.3 billed? By token, like other hiapi text models. See pricing for current rates rather than relying on a number in this post.









