Responses
The OpenAI-compatible Responses API for GLM 5 and Codex — request shape, streaming events, which models accept it, and how it differs from Chat Completions.
Responses
GLM5 provides a Responses-compatible endpoint for Codex Desktop, Codex CLI, and other clients that use the OpenAI Responses API.
Endpoint
POST https://glm5.app/api/v1/responses
Authenticate with a GLM5 API key:
Authorization: Bearer sk-glm5-...
Content-Type: application/json
Text response
Use glm-5.3-flash as the default model ID for new integrations:
curl https://glm5.app/api/v1/responses \
-H "Authorization: Bearer $GLM5_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3-flash",
"input": "Review this function for edge cases.",
"max_output_tokens": 800
}'
The response follows the standard Responses shape, including id, object: "response", status, output, output_text, model, and usage.
Input items
input can be a string or an array of standard input items. Message items with
user, developer, or system roles are supported. Send the complete input
history on every request; GLM5 does not persist Responses state server-side.
Streaming
Set stream to true to receive Server-Sent Events. The stream includes the
standard lifecycle events, including response.created,
response.output_text.delta, response.output_text.done, and
response.completed.
curl --no-buffer https://glm5.app/api/v1/responses \
-H "Authorization: Bearer $GLM5_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3-flash",
"input": "Explain this error in one paragraph.",
"stream": true
}'
Function calling
Function tools use the Responses format. GLM5 returns function_call output
items; execute the function in your client, then send a function_call_output
item in the next request.
{
"model": "glm-5.3-flash",
"input": "Check the current project status.",
"tools": [
{
"type": "function",
"name": "shell",
"description": "Run a safe shell command.",
"parameters": {
"type": "object",
"properties": { "command": { "type": "string" } },
"required": ["command"]
}
}
]
}
The Responses endpoint shares model availability, API keys, credits, rate
limits, and spend limits with /v1/chat/completions. It does not execute
client functions or provide built-in web search on your behalf.
Retry Aware Requests
Use Idempotency-Key for any request a client may retry after a network drop.
The key creates one durable request record for the same API key and body. A
duplicate returns the original request_id plus a status_url instead of
starting another model call or another credit reservation.
Idempotency-Key: codex:turn_01JQ9KPC3H5YQ2T8
Query GET /api/v1/requests/{request_id} with the same API key to inspect
whether the task is processing, succeeded, failed, or was cancelled. The
endpoint exposes usage and safe failure details, but does not replay model
output after a stream disconnect; GLM5 deliberately does not retain prompt or
completion content for that purpose. To stop an active request, streaming or
non-streaming, use POST /api/v1/requests/{request_id}/cancel; it returns
202 before the final cancelled state is written.