2026年4月、Z.ai(旧称 Zhipu AI)は GLM-5.1 をリリースしました。これはオープンソースかつ MIT ライセンスのフラッグシップモデルで、公開直後に SWE-Bench Pro でスコア 58.4% を記録し、GPT-5.4(57.7%)や Claude Opus 4.6(57.3%)を上回ってトップに立ちました。200K のコンテキストウィンドウ、ネイティブな長時間エージェント機能(最大8時間の自律実行)、そして世界最高水準のクローズドモデルに並ぶプロダクション級のコーディング性能により、GLM-5.1 は AI エージェント、コーディングアシスタント、複雑なワークフローを構築する開発者にとっての定番モデルとなりました。
GLM-5.1とは? 最新情報・機能・2026年に重要な理由
2026年4月7日、Z.ai は GLM-5.1 のフルウェイトを MIT ライセンスの下で Hugging Face(zai-org/GLM-5.1)にてオープンソース化し、商用利用・ファインチューニング・ローカルデプロイを可能にしました。同モデルは即座に SWE-Bench Pro でスコア 58.4 を記録し、GPT-5.4(57.7)、Claude Opus 4.6(57.3)、Gemini 3.1 Pro(54.2)を上回りました。
from openai import OpenAI
import os
client = OpenAI(
api_key=os.getenv("COMETAPI_KEY"), # or Z.ai key
base_url="https://api.cometapi.com/v1" # or "https://api.z.ai/api/paas/v4/"
)
response = client.chat.completions.create(
model="glm-5-1",
messages=[
{"role": "system", "content": "You are a world-class AI engineering assistant."},
{"role": "user", "content": "Write a FastAPI endpoint that serves GLM-5.1 completions with rate limiting."}
],
temperature=0.8,
max_tokens=2048,
thinking={"type": "enabled"} # Enables visible reasoning_content
)
print(response.choices[0].message.content)
print("Reasoning:", getattr(response.choices[0].message, "reasoning_content", "None"))
print("Usage:", response.usage)
ストリーミング版(リアルタイム出力):
stream = client.chat.completions.create(
model="glm-5-1",
messages=[{"role": "user", "content": "Generate a complete React + Tailwind dashboard for a SaaS AI coding tool."}],
stream=True,
temperature=0.9
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
tools = [
{
"type": "function",
"function": {
"name": "web_search",
"description": "Search the web for latest information",
"parameters": {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": ["query"]
}
}
},
{
"type": "function",
"function": {
"name": "generate_code",
"description": "Generate Python code for a given task",
"parameters": {"type": "object", "properties": {"task": {"type": "string"}}}
}
}
]
response = client.chat.completions.create(
model="glm-5-1",
messages=[{"role": "user", "content": "Research the latest SWE-Bench results and generate a benchmark comparison script."}],
tools=tools,
tool_choice="auto"
)
# Handle tool_calls in response.choices[0].message.tool_calls
構造化 JSON 出力(エージェントに最適)
response = client.chat.completions.create(
model="glm-5-1",
messages=[{"role": "user", "content": "Extract name, price, and features from this product description as JSON."}],
response_format={"type": "json_object"}
)