Skip to content

GLM-5 API ​

Chat, streaming, function calling, and Anthropic Messages integration.

Model ID: glm-5

Context: 200K tokens. Text input and output.

OpenAI Chat Completions ​

python
from openai import OpenAI
import os
client = OpenAI(api_key=os.environ["MODELFOLD_API_KEY"], base_url="https://modelfold.ai/v1")
result = client.chat.completions.create(model="glm-5", max_tokens=1024, messages=[{"role":"user","content":"Hello"}])
print(result.choices[0].message.content)

Set stream=True to consume SSE chunks. Use OpenAI function schemas for tools and tool_choice. Your application executes the returned tool calls.

Anthropic Messages ​

python
from anthropic import Anthropic
import os
client = Anthropic(api_key=os.environ["MODELFOLD_API_KEY"], base_url="https://modelfold.ai/anthropic")
message = client.messages.create(model="glm-5", max_tokens=1024, messages=[{"role":"user","content":"Hello"}])
print(message.content)

The native route is POST /anthropic/v1/messages. Streaming is supported; tools use Anthropic input_schema. Responses API and server-side count_tokens are unavailable; estimate tokens on the client.

Parameters ​

FieldDescription
modelglm-5
messagesRequired. Include conversation history explicitly.
max_tokensOutput limit, including reasoning tokens.
thinking.typeenabled / disabled
streamtrue / false
tools / tool_choiceFunction definitions and selection policy.

Usage and caching ​

Requests settle once from actual input, cached input, and output tokens. Failed requests are reversed; automatic retries do not create duplicate settlements.

The first request is generally uncached. Reuse an identical prefix for possible cache hits on later requests; rely on cached-token usage returned by the API. Cache hits are not guaranteed. Reasoning tokens count as output.

Vision input ​

This model accepts text. Choose GLM-4.6V for images.

ModelFold — one API for all the best AI models.