HiAPI
  • Models
  • Pricing
Search

Search HiAPI models, tools, and resources.

  • Models
  • Pricing
HiAPI

One API, All AI Models

Generate images, video, and audio with leading models through one production-ready API.

Get a free API key

AI Image API

  • All image models
  • GPT Image 2.5 Flare
  • GPT Image 2.5 Sunburst
  • GPT Image 2
  • Nano Banana 2
  • Seedream 5.0 Pro
  • Qwen Image 2.0 Pro
  • FLUX 1.1 Pro

AI Video API

  • All video models
  • Seedance 2.5
  • FLUX.3 Video
  • Seedance 2.0
  • Veo 3.1
  • Kling 3.0 Omni

AI Audio API

  • All audio models
  • MiniMax Music 2.6
  • MiniMax Music 1.5
  • ElevenLabs v3
  • Text to music
  • Text to speech

Product

  • Model marketplace
  • Playground
  • Pricing
  • Image API Cost Calculator
  • Free GPT Image 2 Generator
  • Free Background Remover
  • Free Nano Banana Image Generator
  • Outfit Preview
  • Product Photo Lab

Developers

  • Agent setup
  • Documentation
  • API Reference
  • Agent Skills
  • LLM integration index
  • Blog

Company

  • About
  • Contact support
  • Terms of Service
  • Privacy Policy

© 2026 hiapi. All rights reserved.

Open source on GitHubPython SDK on PyPI
  • What you'll build
  • Minimal runnable example
  • Production patterns
  • Reasoning tokens will eat a low max_tokens budget
  • Streaming
  • Tool calls
  • Error handling
  • Related resources
  • FAQ
Back to blog
TutorialSep 17, 2026

How to Use glm-5.3 via the hiapi API: curl, Python, and a Working Request

hiapiglm-5.3Chat Completions APIAPI TutorialZhipu

Latest models

  • GPT Image 2.5 FlareFrom $0.050/image
  • GPT Image 2.5 SunburstFrom $0.050/image
  • GPT Image 2From $0.030/image
  • Nano Banana 2From $0.051/image
View all models

Explore models

TextChat and reasoningImageGenerate and editVideoText and image to videoAudioSpeech and music
Contents
  • What you'll build
  • Minimal runnable example
  • Production patterns
  • Reasoning tokens will eat a low max_tokens budget
  • Streaming
  • Tool calls
  • Error handling
  • Related resources
  • FAQ

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.

Latest models

Explore models

Generate it with HiAPI

Choose a model, enter your prompt, and see the result.

Start generatingView model pricing

HiAPI Blog

Related articles

View all articles
How to Use Claude Sonnet 4.6 via the hiapi API

How to Use Claude Sonnet 4.6 via the hiapi API

How to Use kimi-k3 via the hiapi API: curl, Python, and a Working Request

How to Use kimi-k3 via the hiapi API: curl, Python, and a Working Request

How to Use lyria-3.5 via the hiapi API: curl, Python, and a Working Request

How to Use lyria-3.5 via the hiapi API: curl, Python, and a Working Request

Multi-Angle Image-to-Video Prompting with minimax-h3-max via the hiapi API

Multi-Angle Image-to-Video Prompting with minimax-h3-max via the hiapi API

GPT Image 2.5 Sunburst Text-to-Image API: A Working curl and Python Guide

GPT Image 2.5 Sunburst Text-to-Image API: A Working curl and Python Guide

How to Use gpt-image-2.5-flare@pro via the hiapi API: curl, Python, and a Working Request

How to Use gpt-image-2.5-flare@pro via the hiapi API: curl, Python, and a Working Request

HiAPI

Generate it with HiAPI

Start generating
View all models
GPT Image 2.5 FlareFrom $0.050/image
GPT Image 2.5 SunburstFrom $0.050/image
GPT Image 2From $0.030/image
Nano Banana 2From $0.051/image
Text
Image
Video
Audio