Use this file to discover all available pages before exploring further.
Tired of limits? GLM Coding Plan — monthly access to world-class models, compatible with top coding tools like Claude Code and Cline. All from just $18/month. Try it now →
Create an API Key in the API Keys management page.
2
Choose Model
The platform offers multiple models, and you can select the appropriate model based on your needs. For detailed model introductions, please refer to the Models & Agents.
GLM-5.1
Zai’s new-generation flagship foundation model, targeting Agentic Engineering, enables a paradigm shift from code to engineering.
GLM-5V-Turbo
Multimodal Coding model, specializing in visual programming.
GLM-Image
Supports text-to-image generation, achieving open-source state-of-the-art (SOTA) in complex scenarios
CogVideoX-3
New frame generation capabilities that significantly improve image stability and clarity
3
Choose the Calling Method
Our platform provides various development approaches; you can select the best fit for your project needs and tech stack.
HTTP API
Standard RESTful API, compatible with all programming languages.
Z.AI Python SDK
Official Python SDK, featuring full type hints and async support.
Z.AI Java SDK
Official Java SDK, designed for high concurrency and availability.
OpenAI Python SDK
OpenAI SDK Compatibility, quickly migrating from OpenAI.
API Reference
Complete API documentation with parameter descriptions.
4
Make API Call
After preparing your API Key and selecting a model, you can start making API calls. Here are examples using curl, Python SDK, and Java SDK:
from openai import OpenAIclient = OpenAI( api_key="your-Z.AI-api-key", base_url="https://api.z.ai/api/paas/v4/")completion = client.chat.completions.create( model="glm-5.1", messages=[ {"role": "system", "content": "You are a smart and creative novelist"}, {"role": "user", "content": "Please write a short fairy tale story as a fairy tale master"} ])print(completion.choices[0].message.content)
Install SDK
# Install or upgrade to latest versionnpm install openai# Or using yarnyarn add openai
Usage Example
import OpenAI from "openai";const client = new OpenAI({ apiKey: "your-Z.AI-api-key", baseURL: "https://api.z.ai/api/paas/v4/"});async function main() { const completion = await client.chat.completions.create({ model: "glm-5.1", messages: [ { role: "system", content: "You are a helpful AI assistant." }, { role: "user", content: "Hello, please introduce yourself." } ] }); console.log(completion.choices[0].message.content);}main();