GLM-4.5-Flash API
Chat, streaming, function calling, and Anthropic Messages integration.
Model ID: glm-4-5-flash
Context: 128K tokens. Text input and output.
OpenAI Chat Completions
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-4-5-flash", 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
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-4-5-flash", 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
| Field | Description |
|---|---|
| model | glm-4-5-flash |
| messages | Required. Include conversation history explicitly. |
| max_tokens | Output limit, including reasoning tokens. |
| thinking.type | enabled / disabled |
| stream | true / false |
| tools / tool_choice | Function 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.
