AI models and chat

Z.ai API (GLM Flash models)

by docs.z.ai

AI models and chat Added on November 1st, 2026
Visit docs.z.ai →

What it does

The Z.ai API gives access to the GLM language models from Zhipu AI for chat, text generation, coding and image understanding. It uses the OpenAI format, so the OpenAI SDKs work after changing the base URL to api.z.ai. Requests are JSON POST calls to the chat completions endpoint, with streaming as an option. The larger GLM models are paid per token. Free with a free API key for the Flash models: GLM-4.7-Flash, GLM-4.5-Flash and GLM-4.6V-Flash.
  • API
  • JSON
  • REST

At a glance

API key
Needed, free · More APIs with a free key
Pricing
Free with a free API key for the Flash models: GLM-4.7-Flash, GLM-4.5-Flash and GLM-4.6V-Flash.
From the browser
Yes (CORS)
Formats
JSON
Interface
REST
Provider
docs.z.ai

More information: https://docs.z.ai/guides/overview/pricing

Is this your service? Show that it is listed

Put this badge on your website or in your README; it links to this page. About the badge

Listed on Free Web Services

docs.z.ai
Z.ai API (GLM Flash models)

Example request

curl

curl -X POST 'https://api.z.ai/api/paas/v4/chat/completions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"model": "glm-4.7-flash", "messages": [{"role": "user", "content": "hello"}]}'

JavaScript

const response = await fetch("https://api.z.ai/api/paas/v4/chat/completions", {
  method: 'POST',
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"model":"glm-4.7-flash","messages":[{"role":"user","content":"hello"}]}),
});
const data = await response.json();
console.log(data);

Python

import requests

response = requests.post(
    "https://api.z.ai/api/paas/v4/chat/completions",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "model": "glm-4.7-flash",
        "messages": [
            {
                "role": "user",
                "content": "hello",
            },
        ],
    },
    timeout=30,
)
print(response.json())

Replace YOUR_API_KEY with your own key. The JavaScript works in a web page as well as in Node.js 18 or newer.

Did it work for you?

Tell us what you found when you tried Z.ai API (GLM Flash models).