Request Body

ParameterTypeRequiredDescription
messagesarrayRequiredA list of messages comprising the conversation. Each message has a role ("system", "user", "assistant", or "tool") and content.
rolestringRequiredThe role of the message author: "system", "user", "assistant", "tool", or "developer".
contentstring | arrayRequiredThe content of the message. Can be a string or an array of content parts (text, image_url).
modelstringOptionalThe model to use. Defaults to "glm-4.7". Available: "glm-5", "glm-4.7", "glm-4.7-flash", "glm-4.6", "glm-4.5", "glm-4.5-air", "minimax-m2.5".
streambooleanOptionalIf true, returns a stream of Server-Sent Events. Default: false.
stream_optionsobjectOptionalOptions for streaming. Set { "include_usage": true } to receive usage stats in the final chunk.
reasoningobjectOptionalControls reasoning behavior for OpenRouter-style routing. Set { "enabled": false } to skip reasoning and stream user-facing content earlier.
reasoning.enabledbooleanOptionalSet to false to skip reasoning output and emit content directly.
thinkingobjectOptionalLegacy compatibility field. Use { "type": "disabled" } for backward compatibility when supported.
temperaturenumberOptionalSampling temperature between 0 and 2. Higher values make output more random. Default: 1.
top_pnumberOptionalNucleus sampling. The model considers tokens with top_p cumulative probability. Default: 1.
max_tokensintegerOptionalMaximum number of tokens to generate. Model maximum: 32,768.
seedintegerOptionalA seed for deterministic generation. Same seed + same input = same output.
stopstring | arrayOptionalUp to 4 sequences where the model will stop generating.
frequency_penaltynumberOptionalPenalizes tokens based on their frequency in the text so far. Range: -2 to 2.
presence_penaltynumberOptionalPenalizes tokens based on whether they appear in the text so far. Range: -2 to 2.
toolsarrayOptionalA list of tools (functions) the model may call. Each tool has a type, name, description, and parameters schema.
tool_choicestring | objectOptionalControls tool calling: "none", "auto", "required", or { type: "function", function: { name: "..." } }.
response_formatobjectOptionalSet { "type": "json_object" } to force JSON output. The model will return valid JSON.
logprobsbooleanOptionalWhether to return log probabilities of output tokens.
top_logprobsintegerOptionalNumber of most likely tokens to return at each position (0-20). Requires logprobs: true.
logit_biasobjectOptionalMap of token IDs to bias values (-100 to 100). Use to increase or decrease likelihood of specific tokens.