Chat Completion
Creates a model response for the given chat conversation, using an OpenAI-compatible request and response shape.
Requires api-subscription-key with beta access to this endpoint. Set "stream": true to receive the reply as server-sent events, ending with a [DONE] line.
Authentication
Bearer authentication of the form Bearer <token>, where token is your auth token.
Request
A list of messages comprising the conversation so far. Roles: system, developer, user, assistant, tool. An assistant message as the last turn is a prior turn, not token-level prefill.
Model IDs accepted by POST /v2/chat/completions and POST /v2/responses:
sarvam-105b— Sarvam flagship chat model.glm5.3— open-source; 1M context, tool calling, visible reasoning.gemma4— open-source; image input, tool calling.deepseekv4-flash— open-source; 1M context, tool calling, reasoning.
GET /v2/models is environment-specific and may omit IDs that completions still accept. A model whose backend has no /v1/responses route fails POST /v2/responses with 502.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
We generally recommend altering this or top_p but not both.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
Must be greater than 0 and at most 1. 0 is invalid; current serving returns 503 model_overloaded rather than a clean 400. Prefer altering this or temperature but not both.
Reasoning effort. Chat accepts none, minimal, low, medium, high, xhigh, and max. Reasoning models such as glm5.3 still think when this is unset. extra_body.chat_template_kwargs.enable_thinking: false is accepted but currently does not disable glm5.3 thinking; low is the practical way to keep the trace short.
If set to true, the model response data will be streamed to the client as it is generated using server-sent events. The chat stream ends with a [DONE] line. Pair with stream_options.include_usage to receive a usage chunk (including reasoning_tokens).
How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
This feature is in Beta.
If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.
Controls which (if any) tool is called by the model.
An object specifying the format that the model must output. Setting { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which guarantees the model generates output matching the supplied JSON Schema. Setting { "type": "json_object" } enables the older JSON mode, which guarantees valid JSON but not a specific schema.
Extra body forwarded to the model. Must not repeat any modelled field and must not carry stream_options — a collision is 400. chat_template_kwargs.enable_thinking is accepted; on live glm5.3 it does not currently turn thinking off.
Top-k sampling. null or -1 disables it. 0 is 400. Values >= 1 are accepted; there is no enforced cap at 100.
Minimum probability mass. Must be between 0 and 1 inclusive. Outside that range is 400.
Repetition penalty. Must be greater than 0 and at most 2. 0 and values above 2 are 400.
Whether the model may emit more than one tool call in one turn. Accepted. On live glm5.3, false does not serialize two requested calls into one.
Only valid with stream: true (otherwise 400). Put this at the top level, not inside extra_body.
Response
A list of chat completion choices. Can be more than one if n is greater than 1.
The Unix timestamp (in seconds) of when the chat completion was created.
The object type, which is always chat.completion.