Skip to main content
POST
BaseURL: The default BaseURL is https://direct.evolink.ai, which has better support for text models and long-lived connections. https://api.evolink.ai is the primary endpoint for multimodal services and serves as a fallback address for text models.
Call GLM in Responses format for text conversations, streaming and function calling, with image understanding and web search available according to the model. See the parameters and model differences below.

Models and parameter differences

Choose a GLM model. All four support text on this endpoint. Optional capabilities vary by model. Responses uses nested reasoning.effort, rather than top-level reasoning_effort or thinking. Reasoning usage is included in output_tokens. Simple tasks may return reasoning_tokens=0; this does not imply that thinking can be disabled. Reasoning effort; low is recommended. Compatibility rules for glm-5.3 / glm-5.3-flash / glm-5.3-flashx minimal and none do not disable thinking on the 5.3 series. Thinking tokens are billed as output. Unrecognized values are unchanged and have no compatibility mapping; use the listed values. These mappings do not apply to glm-5.2. On this endpoint, glm-5.2 may still produce reasoning tokens with none. This value does not guarantee that thinking is disabled.

System prompts and multi-turn conversations

instructions: System instructions. glm-5.3-flash supports this field when input is a string. When input is a message array, put the system prompt in the first role=system message.
Store the response for later reference. glm-5.3-flash and glm-5.3-flashx support multi-turn conversations using store=true with previous_response_id. glm-5.2 does not support response-ID continuation; store=true does not enable it. Include the full history in input instead. The top-level id of the previous response. glm-5.3-flash and glm-5.3-flashx support this with store=true and the same model. Pass the response id unchanged, not an item id from output. glm-5.2 returns 400 for this field. For conversations across models, omit it and include the full history in input.

Streaming responses

Enable SSE streaming. Read answer text from delta in response.output_text.delta. The successful terminal event is response.completed. Also end the turn and handle response.incomplete, response.failed or error. Do not wait only for [DONE] or connection closure. Stop reading after a terminal event. HTTP 200 only means that the stream was established; check the final event status. A tool-call turn may end with response.completed and still require your application to execute the function and send another request.

Function calling

Choose the function example in the request menu. Responses function definitions use a flat structure:
  1. Traverse response.output and collect all items with type=function_call.
  2. Parse and validate the arguments JSON string, then execute each function in your application.
  3. Append the entire previous output to the history. Add a function_call_output for each call, using the original call_id and a string output.
  4. Send the updated history as input in the next request. The function-result example shows this structure.
parallel_tool_calls: Whether multiple tools may be called in a turn. false does not guarantee a single function call. Clients should traverse and handle every function_call.

Images, search and JSON output

For glm-5.3-flash and glm-5.3-flashx, mix input_text and input_image in the user message content array. Pass a public image URL or Base64 Data URL in image_url. Use text only for glm-5.3 and glm-5.2. Declare tools: [{"type":"web_search"}]. Search runs on the server and returns web_search_call items and answer text. Check the output items to see whether search was used. Searches may incur per-call fees in addition to token charges; see model pricing. To continue after a search, append the entire previous output, including web_search_call and message, to input, then add your new question. Preserve original fields such as id, status, and action. The server has already executed the search, so do not create a function_call_output for web_search_call. See the web_search_history request example. text.format.type: Output format: text for plain text or json_object for a JSON object. With json_object, explicitly request valid JSON in the prompt and parse and validate it in your client. Strict JSON Schema constraints are not provided; do not rely on json_schema or strict=true to enforce a structure.

Responses and usage

Ordered output items. Extract text from content entries with type=output_text inside type=message items. Reasoning may precede the answer, and function_call turns may contain no answer text. Do not always read output[0]. output_text: Optional aggregated answer text; it may be absent. General-purpose clients should traverse output. output_text in message items; possibly reasoning_text in reasoning items. Reasoning may also be returned as summary_text. Do not assume every reasoning item has content.
  • usage.input_tokens: Total input tokens, including cached tokens. usage.input_tokens_details.cached_tokens: Cached subset of input tokens; do not add it to input_tokens again. Prefix caching is automatic and requires no explicit cache_control. Use the returned value for the number of cache hits.
  • usage.output_tokens: Total output tokens, including reasoning tokens. usage.output_tokens_details.reasoning_tokens: Subset of output tokens used for reasoning; do not count it again in output_tokens. This detail may be absent or zero.
status=incomplete with incomplete_details.reason=max_output_tokens means the budget was exhausted. There may be reasoning without an answer; increase the output limit.

Authorizations

Authorization
string
header
required

Send Bearer YOUR_API_KEY in the Authorization header.

Body

application/json
model
enum<string>
default:glm-5.3-flash
required

Choose a GLM model. All four support text on this endpoint. Optional capabilities vary by model.

Available options:
glm-5.3,
glm-5.3-flash,
glm-5.3-flashx,
glm-5.2
Example:

"glm-5.3-flash"

input
required

Required. A text string or an array of Responses input items. Arrays accept messages, returned model output items and function_call_output. For multi-turn conversations, include the full history in each request. Put the system prompt first as a role=system message. Images use input_image, supported only by glm-5.3-flash and glm-5.3-flashx. Do not use the Chat Completions messages / image_url block format.

Example:

"Introduce yourself in one sentence."

max_output_tokens
integer

Maximum output tokens for this generation, including reasoning. Start at 1024 and adjust for the task. A small budget may be exhausted during reasoning, leaving only reasoning items and no answer. Check status and incomplete_details. The parameter name is max_output_tokens, not max_tokens.

Required range: x >= 1
Example:

1024

stream
boolean
default:false

Enable SSE streaming. Read answer text from delta in response.output_text.delta. The successful terminal event is response.completed. Also end the turn and handle response.incomplete, response.failed or error. Do not wait only for [DONE] or connection closure.

reasoning
object

Responses uses nested reasoning.effort, rather than top-level reasoning_effort or thinking. Reasoning usage is included in output_tokens. Simple tasks may return reasoning_tokens=0; this does not imply that thinking can be disabled.

instructions
string

System instructions. glm-5.3-flash supports this field when input is a string. When input is a message array, put the system prompt in the first role=system message.

tools
object[]

Supports client-side function tools and server-side web_search. Declare functions with flat name / description / parameters fields, not a nested Chat Completions function object. Your application executes function_call and returns the result. web_search runs on the server; actual searches may incur per-call charges in addition to tokens. See model pricing.

tool_choice

auto lets the model choose; none disables tools; required requires a tool call. To select a function, use {"type":"function","name":"get_temperature"}. Forced selection behavior is not guaranteed to be identical for every model and tool combination.

Available options:
auto,
none,
required
Example:

"auto"

parallel_tool_calls
boolean

Whether multiple tools may be called in a turn. false does not guarantee a single function call. Clients should traverse and handle every function_call.

text
object

Output format. Examples use json_object. HTTP 200 does not guarantee JSON Schema compliance.

store
boolean

Store the response for later reference. glm-5.3-flash and glm-5.3-flashx support multi-turn conversations using store=true with previous_response_id. glm-5.2 does not support response-ID continuation; store=true does not enable it. Include the full history in input instead.

previous_response_id
string

The top-level id of the previous response. glm-5.3-flash and glm-5.3-flashx support this with store=true and the same model. Pass the response id unchanged, not an item id from output. glm-5.2 returns 400 for this field. For conversations across models, omit it and include the full history in input.

Example:

"Response ID returned in the previous turn"

metadata
object

Custom string key-value metadata, available in response metadata. Do not include keys or sensitive information.

Example:
temperature
number

Sampling parameter. The effective range and behavior depend on the model. It does not guarantee deterministic output and can be omitted for reasoning tasks.

top_p
number

Sampling parameter. The effective range and behavior depend on the model. It can usually be omitted.

Response

Generation completed or returned an incomplete result; check status. Streaming returns text/event-stream.

id
string

ID of this response. Pass it unchanged as previous_response_id.

Example:

"response_demo"

object
string
Allowed value: "response"
created_at
integer

Creation time in Unix seconds.

model
string
Example:

"glm-5.3-flash"

status
enum<string>

completed means generation for this turn has ended, possibly with tool calls only. incomplete means the output is incomplete. Check both output and error.

Available options:
completed,
incomplete,
failed,
in_progress,
queued
output
object[]

Ordered output items. Extract text from content entries with type=output_text inside type=message items. Reasoning may precede the answer, and function_call turns may contain no answer text. Do not always read output[0].

output_text
string

Optional aggregated answer text; it may be absent. General-purpose clients should traverse output.

usage
object
error
object | null

Response error, normally null on success.

incomplete_details
object
metadata
object | null