Text · Z.ai

GLM API

Z.ai GLM API access via RunAPI — MIT-licensed MoE models with up to 200K context, leading open-weight coding benchmarks.

Operational · 8 variants · from $0.0001
runapi.ai
# Base URL
https://runapi.ai

# Endpoints
POST /v1/chat/completions
POST /v1/responses
POST /v1/messages
POST /v1beta/models/{model}:generateContent
POST /v1beta/models/{model}:streamGenerateContent
curl https://runapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $RUNAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "glm-5.2",
  "messages": [
    {
      "role": "user",
      "content": "Read this multi-file repository, find the failing integration test, and propose a patch with an explanation of the root cause."
    }
  ]
}'
from openai import OpenAI

client = OpenAI(
    base_url="https://runapi.ai/v1",
    api_key="your-runapi-key"
)

response = client.chat.completions.create(
    model="glm-5.2",
    messages=[{"role": "user", "content": "Read this multi-file repository, find the failing integration test, and propose a patch with an explanation of the root cause."}]
)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://runapi.ai/v1",
  apiKey: "your-runapi-key"
});

const response = await client.chat.completions.create({
  model: "glm-5.2",
  messages: [{ role: "user", content: "Read this multi-file repository, find the failing integration test, and propose a patch with an explanation of the root cause." }]
});
https://runapi.ai 5 endpoints
OVERVIEW

GLM is Z.ai's family of MIT-licensed Mixture-of-Experts language models. GLM-4.5 (355B total / 32B active, 128K context) introduced the open-weight MoE line with a flagship and a lighter Air tier. GLM-4.6 and 4.7 extend to 200K context with stronger code generation — 4.7 reaches 73.8% on SWE-bench. The GLM-5 series (744B / 40B active, 200K context) pushes further to 77.8% SWE-bench Verified, and GLM-5.1 holds the top open-weight score on SWE-bench Pro at 58.4%. All are available through RunAPI with one key and per-token billing.

  • Multiple variants for different speed, quality, and cost tiers
  • Model skill includes docs, schemas, pricing, and setup notes
  • Works with Claude Code, Codex, Gemini CLI, Cursor, and VS Code
  • Single API key and unified billing across all variants
  • Async task management with polling and webhook callbacks
  • Failed generations are not charged
VARIANTS

Compare all API variants

Variant Billing Pricing
glm-4.5 1K tokens Input $0.41 / 1M tokens | Output $1.61 / 1M tokens View →
glm-4.5-air 1K tokens Input $0.10 / 1M tokens | Output $0.55 / 1M tokens View →
glm-4.6 1K tokens Input $0.60 / 1M tokens | Output $1.22 / 1M tokens View →
glm-4.7 1K tokens Input $0.60 / 1M tokens | Output $1.19 / 1M tokens View →
glm-5 1K tokens Input $1.00 / 1M tokens | Output $1.60 / 1M tokens View →
glm-5-turbo 1K tokens Input $1.20 / 1M tokens | Output $2.00 / 1M tokens View →
glm-5.1 1K tokens Input $1.40 / 1M tokens | Output $2.20 / 1M tokens View →
glm-5.2 1K tokens Input $0.70 / 1M tokens | Output $2.20 / 1M tokens View →
API

GLM API endpoints

Use the OpenAI or Anthropic SDK with your RunAPI key. No extra SDK required.

Endpoint Protocol
/v1/chat/completions OpenAI compatible
/v1/responses OpenAI Responses
/v1/messages Anthropic compatible
/v1beta/models/{model}:generateContent Gemini generateContent
/v1beta/models/{model}:streamGenerateContent Gemini streamGenerateContent
HOW IT WORKS

From model skill to first result in four steps

01

Choose a model

Browse the model catalog and pick the model and variant that match your output type, quality bar, and latency target. Each variant page shows its model ID, pricing, and parameter constraints so you can compare before committing.

02

Configure

Set your RunAPI API key as an environment variable and install the model skill in your coding workspace. The skill loads docs, typed schemas, pricing notes, and setup steps so your agent has the right context from the start.

03

Call

Use the skill instructions to add the model feature inside your application. Send a POST request with your prompt, model ID, and parameters. RunAPI routes the request, manages the async lifecycle, and returns structured JSON.

04

Receive

Poll by task ID for completion, stream results end-to-end when supported, or configure a webhook callback URL to receive results automatically. The CLI provides a built-in wait command, and the SDKs offer both polling and callback patterns.

CONTEXT

What is the GLM API?

GLM models from Z.ai are MIT-licensed MoE LLMs spanning 128K–200K context. GLM-5.1 leads open-weight models on SWE-bench Pro. Through RunAPI they share a single API key with pay-as-you-go token billing, callable from the OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages surfaces.

Provider
Z.ai
Modality
Text
WHY RUNAPI

Why route the GLM API through RunAPI

One auth, every provider

A single RunAPI API key unlocks the whole model catalog across all providers. No separate accounts to create, no API keys to rotate per integration, and no credential management overhead. Add a new model to your app by changing one parameter.

Unified pricing & billing

Per-call pricing in USD, billed monthly into a single invoice. No subscription tiers, no minimum spend, and failed generations are never charged. The pricing page and check_pricing API show exact costs before you commit to a model.

Schema-first SDK

Typed schemas, parameter constraints, and setup notes are packaged in the model skill so your implementation starts from the right contract. The skill loads into Claude Code, Codex, Gemini CLI, Cursor, and VS Code — your agent knows the correct request shape before you write a line of code.

FAQ

Common questions

What are the GLM models good at?

Coding and agentic tool use. GLM-5.1 leads open-weight models on SWE-bench Pro (58.4%) and scores 95.3% on AIME 2026. The full line is strong at multi-step tool calling, code generation across large codebases, and mathematical reasoning.

What is the difference between glm-4.5 and glm-4.5-air?

glm-4.5 is the 355B flagship (32B active parameters) with 128K context; glm-4.5-air is a lighter 106B MoE (12B active) for faster, lower-cost everyday work.

How does GLM-5 compare to GLM-4.7?

GLM-5 scales to 744B total / 40B active with 256 experts, versus GLM-4.7's 358B / 32B. SWE-bench Verified jumps from 73.8% to 77.8%. Both share 200K context.

Which SDKs can call GLM through RunAPI?

Point the OpenAI SDK (Chat Completions or Responses) or the Anthropic Messages SDK at RunAPI and pass the GLM model id; the proxy adapts the protocol for you.

How is GLM billed?

Per token, pay-as-you-go, at RunAPI's published input and output rates for each GLM model — no subscription.

Which variant should I start with?

Pick the cheapest variant that meets your quality bar. Most teams start on the fast variant and graduate to pro for production.

Is there a free tier?

New accounts get free first calls on every model. After that, pay per call.

Do you stream results?

Where streaming is available, RunAPI streams end-to-end.

How are failures billed?

Failed generations are not charged.

Are outputs cached?

Generated outputs are stored and retrievable by task ID. Inputs are not cached.

Can I use commercially?

Yes — commercial use is included for every variant unless a model license explicitly restricts it, which is called out on the variant page.

What about rate limits?

Per-key rate limits scale with usage tier. See pricing page for current limits.

Where can I report issues?

Open an issue on the public GitHub repo or email support.

START NOW

Start building with the GLM API.