# Z.ai API (GLM Flash models)

Category: [AI models and chat](https://free-web-services.com/web-services/ai/llm/)  
Page: https://free-web-services.com/web-services/ai/llm/z-ai-api.html  
Documentation: https://docs.z.ai/guides/overview/pricing

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 key: Needed, free
- 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

Example request:

```sh
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"}]}'
```

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

