Endpoint
sk_live_ API key in the Authorization header as Bearer YOUR_API_KEY. The examples use glm-5.3-flash. For other model IDs, see Available models.
Basic request
- Python
- TypeScript
- cURL
Request parameters
Other OpenAI chat completion parameters are passed to the model, and support for them depends on the model.
Messages
Each message has arole and content:
system: instructions that set the assistant’s behavior. Put it first.user: a message from the user.assistant: an earlier reply from the model.
Response
usage object reports the tokens used by the request:
prompt_tokens: input tokens. When present,prompt_tokens_details.cached_tokensis the part served from the prompt cache.completion_tokens: output tokens, including any thinking. The thinking count is incompletion_tokens_details.reasoning_tokensforglm-5.3-flash, and in a top-levelreasoning_tokensfield forqwen3.8-27b.
usage can vary by model.
Reasoning models
Reasoning models think before they answer.glm-5.3-flash and qwen3.8-27b return their thinking in a reasoning_content field, next to content in the message and in each streamed delta. The answer in content doesn’t include the thinking.
Other models may not return their thinking. If a model includes its thinking in content between <think> and </think> tags, strip that section if you only want the answer.
Keep these in mind when you use a reasoning model:
- Thinking counts against
max_tokens. If the model uses upmax_tokenswhile it’s still thinking, the response ends withfinish_reasonset to"length"and an empty answer. Raisemax_tokensand try again. Thinking length varies by prompt, and even a short question can use more than 1,000 tokens of thinking. Always setmax_tokens: withglm-5.3-flash, leaving it out means a limit of 2,048, and withqwen3.8-27bit means no limit until the context window fills. - Thinking is billed as output tokens. It’s included in
completion_tokens. See Response for where each model reports how much of it was thinking. - Leave earlier thinking out of the conversation history. In later requests, send only each earlier reply’s answer as the
assistantmessage. Withglm-5.3-flash, thinking sent back inreasoning_contentis counted as input tokens on every turn. - Stop sequences also apply to the thinking. With
glm-5.3-flash, if astopsequence appears while the model is thinking, the response ends there, before any answer. Choose stop sequences that won’t appear in the reasoning.
Streaming
Setstream to true to receive tokens as they’re generated. The response is a stream of server-sent events. Each data: line holds a chunk with the next piece of text in choices[0].delta.content, and the stream ends with data: [DONE]. With glm-5.3-flash, the thinking streams first in choices[0].delta.reasoning_content.
To get token counts for a streamed request, set stream_options to {"include_usage": true}. A chunk at the end of the stream then carries the usage object.
- OpenAI SDK
- Python
- cURL
Time limits
Each request has a time limit, including streamed requests:
Non-streaming requests also time out if the response doesn’t start within about 60 seconds. For long generations, set
stream to true.
Tool calling
Passtools to let the model call functions you define. When the model decides to call one, the response has finish_reason set to "tool_calls" and a tool_calls array in the message. Each call has an id, the function name, and its arguments as a JSON string. Your code runs the function, then sends the result back so the model can answer:
- Add the assistant message from the response, with its
tool_calls, tomessages. - For each call, add a message with
roleset to"tool",tool_call_idset to the call’sid, and the result as a string incontent. - Send the request again with the same
tools. The model answers using the results.
glm-5.3-flash, glm-5.3, and qwen3.8-27b. Support on other models depends on the model.
- Python
- cURL
Structured output
Setresponse_format to get JSON back in content:
{"type": "json_schema", "json_schema": {...}}returns JSON that follows the schema you provide.{"type": "json_object"}returns valid JSON without a fixed schema. Describe the keys you want in your prompt.
glm-5.3-flash, glm-5.3, and qwen3.8-27b. Support on other models depends on the model.
- Python
- cURL
List models
GET /v1/models returns the models you can call, in the OpenAI list format. It needs your API key, like other requests.
data has the model id to pass in the model field, and owned_by, the model’s creator:
OpenAI SDK compatibility
Point an OpenAI SDK at the Hyperbolic base URL and use your Hyperbolic API key:- Python
- Node.js
Next steps
Errors
Error codes and how to handle them.
Inference overview
Pricing, billing, and access requirements.

