Z.ai Open Platform API

OpenAI-compatible chat completions plus vision, image, video, web search, audio, embeddings, fine-tuning, and agent endpoints. International base URL https://api.z.ai/api; legacy China base URL https://open.bigmodel.cn/api/paas/v4.

OpenAPI Specification

zhipu-ai-openapi.json Raw ↑
{
  "openapi": "3.0.1",
  "info": {
    "title": "Z.AI API",
    "description": "Z.AI API available endpoints",
    "license": {
      "name": "Z.AI Developer Agreement and Policy",
      "url": "https://chat.z.ai/legal-agreement/terms-of-service"
    },
    "version": "1.0.0",
    "contact": {
      "name": "Z.AI Developers",
      "url": "https://chat.z.ai/legal-agreement/privacy-policy",
      "email": "[email protected]"
    }
  },
  "servers": [
    {
      "url": "https://api.z.ai/api",
      "description": "Production server"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/paas/v4/chat/completions": {
      "post": {
        "description": "Create a chat completion model that generates AI replies for given conversation messages. It supports multimodal inputs (text, images, audio, video, file), offers configurable parameters (like temperature, max tokens, tool use), and supports both streaming and non-streaming output modes.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "title": "Text Model",
                    "$ref": "#/components/schemas/ChatCompletionTextRequest"
                  },
                  {
                    "title": "Vision Model",
                    "$ref": "#/components/schemas/ChatCompletionVisionRequest"
                  }
                ]
              },
              "examples": {
                "Basic Example": {
                  "value": {
                    "model": "glm-5.1",
                    "messages": [
                      {
                        "role": "system",
                        "content": "You are a useful AI assistant."
                      },
                      {
                        "role": "user",
                        "content": "Please tell us about the development of artificial intelligence."
                      }
                    ],
                    "temperature": 1,
                    "stream": false
                  }
                },
                "Stream Example": {
                  "value": {
                    "model": "glm-5.1",
                    "messages": [
                      {
                        "role": "user",
                        "content": "Write a poem about spring."
                      }
                    ],
                    "temperature": 1,
                    "stream": true
                  }
                },
                "Thinking Example": {
                  "value": {
                    "model": "glm-5.1",
                    "messages": [
                      {
                        "role": "user",
                        "content": "Write a poem about spring."
                      }
                    ],
                    "thinking": {
                      "type": "enabled"
                    },
                    "stream": true
                  }
                },
                "Multi Conversation": {
                  "value": {
                    "model": "glm-5.1",
                    "messages": [
                      {
                        "role": "system",
                        "content": "You are a professional programming assistant."
                      },
                      {
                        "role": "user",
                        "content": "What is recursion?"
                      },
                      {
                        "role": "assistant",
                        "content": "Recursion is a programming technique where a function calls itself to solve a problem... What is recursion"
                      },
                      {
                        "role": "user",
                        "content": "Can you give me an example of Python recursion?"
                      }
                    ],
                    "stream": true
                  }
                },
                "Image Visual Example": {
                  "value": {
                    "model": "glm-5v-turbo",
                    "messages": [
                      {
                        "role": "user",
                        "content": [
                          {
                            "type": "image_url",
                            "image_url": {
                              "url": "https://cdn.bigmodel.cn/static/logo/register.png"
                            }
                          },
                          {
                            "type": "image_url",
                            "image_url": {
                              "url": "https://cdn.bigmodel.cn/static/logo/api-key.png"
                            }
                          },
                          {
                            "type": "text",
                            "text": "What are the pics talk about?"
                          }
                        ]
                      }
                    ]
                  }
                },
                "Video Visual Example": {
                  "value": {
                    "model": "glm-5v-turbo",
                    "messages": [
                      {
                        "role": "user",
                        "content": [
                          {
                            "type": "video_url",
                            "video_url": {
                              "url": "https://cdn.bigmodel.cn/agent-demos/lark/113123.mov"
                            }
                          },
                          {
                            "type": "text",
                            "text": "What are the video show about?"
                          }
                        ]
                      }
                    ]
                  }
                },
                "File Visual Example": {
                  "value": {
                    "model": "glm-5v-turbo",
                    "messages": [
                      {
                        "role": "user",
                        "content": [
                          {
                            "type": "file_url",
                            "file_url": {
                              "url": "https://cdn.bigmodel.cn/static/demo/demo2.txt"
                            }
                          },
                          {
                            "type": "file_url",
                            "file_url": {
                              "url": "https://cdn.bigmodel.cn/static/demo/demo1.pdf"
                            }
                          },
                          {
                            "type": "text",
                            "text": "What are the files show about?"
                          }
                        ]
                      }
                    ]
                  }
                },
                "Function Call Example": {
                  "value": {
                    "model": "glm-5.1",
                    "messages": [
                      {
                        "role": "user",
                        "content": "Is there an example of how the weather in Beijing is today?"
                      }
                    ],
                    "tools": [
                      {
                        "type": "function",
                        "function": {
                          "name": "get_weather",
                          "description": "Get weather information for the specified city.",
                          "parameters": {
                            "type": "object",
                            "properties": {
                              "city": {
                                "type": "string",
                                "description": "City Name"
                              }
                            },
                            "required": [
                              "city"
                            ]
                          }
                        }
                      }
                    ],
                    "tool_choice": "auto",
                    "temperature": 0.3
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/videos/generations": {
      "post": {
        "description": "CogVideoX is a video generation large model developed by Z.AI, equipped with powerful video generation capabilities. Simply inputting text or images allows for effortless video creation.\n\nVidu: A high-performance video large model that combines high consistency and high dynamism, with precise semantic understanding and exceptional reasoning speed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "title": "CogVideoX-3",
                    "$ref": "#/components/schemas/CogVideoX3Request"
                  },
                  {
                    "title": "Vidu: Text to Video",
                    "$ref": "#/components/schemas/ViduText2VideoRequest"
                  },
                  {
                    "title": "Vidu: Image to Video",
                    "$ref": "#/components/schemas/ViduImage2VideoRequest"
                  },
                  {
                    "title": "Vidu: First & Last Frame to Video",
                    "$ref": "#/components/schemas/ViduFrames2VideoRequest"
                  },
                  {
                    "title": "Vidu: Ref to Video",
                    "$ref": "#/components/schemas/ViduReference2VideoRequest"
                  }
                ]
              },
              "examples": {
                "Text to Video Example": {
                  "value": {
                    "model": "cogvideox-3",
                    "prompt": "A cat is playing with a ball.",
                    "quality": "quality",
                    "with_audio": true,
                    "size": "1920x1080",
                    "fps": 30
                  }
                },
                "Image to Video Example": {
                  "value": {
                    "model": "cogvideox-3",
                    "image_url": "https://img.iplaysoft.com/wp-content/uploads/2019/free-images/free_stock_photo.jpg",
                    "prompt": "Make the picture move",
                    "quality": "quality",
                    "with_audio": true,
                    "size": "1920x1080",
                    "fps": 30
                  }
                },
                "First Last Frame to Video": {
                  "value": {
                    "model": "cogvideox-3",
                    "image_url": [
                      "https://gd-hbimg.huaban.com/ccee58d77afe8f5e17a572246b1994f7e027657fe9e6-qD66In_fw1200webp",
                      "https://gd-hbimg.huaban.com/cc2601d568a72d18d90b2cc7f1065b16b2d693f7fa3f7-hDAwNq_fw1200webp"
                    ],
                    "prompt": "Make the picture move",
                    "quality": "quality",
                    "with_audio": true,
                    "size": "1920x1080",
                    "fps": 30
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoResponse"
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/async-result/{id}": {
      "get": {
        "description": "This endpoint is used to query the result of an asynchronous request.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Task id."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "title": "Video Generation",
                      "$ref": "#/components/schemas/AsyncVideoGenerationResponse"
                    },
                    {
                      "title": "Image Generation",
                      "$ref": "#/components/schemas/AsyncImageGenerationResponse"
                    }
                  ]
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/images/generations": {
      "post": {
        "summary": "Generate Image",
        "description": "Use [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateImageRequest"
              },
              "examples": {
                "Generate Image Example": {
                  "value": {
                    "model": "glm-image",
                    "prompt": "A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.",
                    "size": "1280x1280"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationResponse"
                }
              }
            }
          },
          "default": {
            "description": "Request Failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/async/images/generations": {
      "post": {
        "summary": "Generate Image (Async)",
        "description": "Use the [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized. Only supports `GLM-Image` model.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AsyncCreateImageRequest"
              },
              "examples": {
                "Image Generation Example": {
                  "value": {
                    "model": "glm-image",
                    "prompt": "A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.",
                    "size": "1280x1280"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AsyncResponse"
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/audio/transcriptions": {
      "post": {
        "summary": "Speech to Text",
        "description": "Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription.",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/AudioTranscriptionRequest"
              },
              "example": {
                "model": "glm-asr-2512",
                "stream": false
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Request processed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudioTranscriptionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/AudioTranscriptionStreamResponse"
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/tokenizer": {
      "post": {
        "summary": "Text Tokenizer",
        "description": "`Tokenizer` is used to split text into `tokens` recognizable by the model and calculate the count. It receives user input text, processes it through the model for tokenization, and finally returns the corresponding `token` count. It is suitable for text length evaluation, model input estimation, dialogue context truncation, cost calculation, etc.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenizerRequest"
              },
              "examples": {
                "Text Tokenization Example": {
                  "value": {
                    "model": "glm-4.6",
                    "messages": [
                      {
                        "role": "user",
                        "content": "What opportunities and challenges will the Chinese large model industry face in 2025?"
                      }
                    ]
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Business processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenizerResponse"
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/layout_parsing": {
      "post": {
        "summary": "Layout Parsing",
        "description": "Use the [GLM-OCR](/guides/vlm/glm-ocr) model to parse the layout of documents and images and extract text content. Support OCR recognition of images and PDF documents, returning detailed layout information and visualization results.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LayoutParsingRequest"
              },
              "examples": {
                "Layout Parsing Example": {
                  "value": {
                    "model": "glm-ocr",
                    "file": "https://cdn.bigmodel.cn/static/logo/introduction.png"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Business processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LayoutParsingResponse"
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/web_search": {
      "post": {
        "description": "The [Web Search](/guides/tools/web-search) is a specialized search engine for large language models. Building upon traditional search engine capabilities like web crawling and ranking, it enhances intent recognition to return results better suited for LLM processing (including webpage titles, URLs, summaries, site names, favicons etc.).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebSearchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebSearchResponse"
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/reader": {
      "post": {
        "tags": [
          "Tools API"
        ],
        "summary": "Web Reader",
        "description": "Reads and parses the content of the specified URL. Supports selectable return formats, cache control, image retention, and summary options.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReaderRequest"
              },
              "examples": {
                "Basic": {
                  "value": {
                    "url": "https://www.example.com"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReaderResponse"
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/paas/v4/files": {
      "post": {
        "description": "This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency.",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "purpose": {
                    "type": "string",
                    "description": "Upload purpose (agent)",
                    "default": "agent",
                    "enum": [
                      "agent"
                    ]
                  },
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`."
                  }
                },
                "required": [
                  "purpose",
                  "file"
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Unique identifier of the uploaded file."
                    },
                    "object": {
                      "type": "string",
                      "description": "Object type."
                    },
                    "bytes": {
                      "type": "integer",
                      "description": "File size in bytes."
                    },
                    "filename": {
                      "type": "string",
                      "description": "Name of the uploaded file."
                    },
                    "purpose": {
                      "type": "string",
                      "description": "Purpose of the uploaded file."
                    },
                    "created_at": {
                      "type": "integer",
                      "description": "Timestamp of file creation."
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents": {
      "post": {
        "description": "General Translation: General Translation API provides large model-based multilingual translation services, including general translation, paraphrase translation, two-step translation, and three-pass translation strategies. It supports automatic language detection, glossary customization, translation suggestions, and streaming output. Users only need to call the Translation API, input the text to be processed, specify the source language (auto-detection supported) and target language to receive high-quality translation results. \n\n Popular Special Effects Videos: Popular special effects videos are intelligent templates launched based on trending features from pan-entertainment platforms, designed to precisely adapt to short video creative production needs. Currently, three effect templates are available: `French Kiss`, `Body Shake Dance`, and `Sexy Me`. After selecting a template, users only need to upload an image and enter corresponding prompts to generate a special effects video. \n\n GLM Slide/Poster Agent: An intelligent creation agent built for working people and creators. It goes beyond traditional engineering-style assembly tools—supporting one-click generation of slides or posters from natural language instructions. By natively integrating content generation with layout aesthetics and design conventions, it helps you quickly produce polished, professional-grade materials while lowering design barriers and boosting creative efficiency.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptLanguage"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "title": "General Translation",
                    "$ref": "#/components/schemas/TranslationAgentRequest"
                  },
                  {
                    "title": "Popular Special Effects Videos",
                    "$ref": "#/components/schemas/SpecialEffectsVideosAgentRequest"
                  },
                  {
                    "title": "GLM Slide/Poster",
                    "$ref": "#/components/schemas/GlmSlideAgentRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processing successful",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "title": "General Translation",
                      "$ref": "#/components/schemas/TranslationAgentResponse"
                    },
                    {
                      "title": "Popular Special Effects Videos",
                      "$ref": "#/components/schemas/SpecialEffectsVideosAgentResponse"
                    },
                    {
                      "title": "GLM Slide/Poster",
                      "$ref": "#/components/schemas/GlmSlideAgentResponse"
                    }
                  ]
                },
                "examples": {
                  "General Translation": {
                    "value": {
                      "id": "<string>",
                      "agent_id": "<string>",
                      "choices": [
                        {
                          "index": 123,
                          "finish_reason": "<string>",
                          "messages": [
                            {
                              "role": "<string>",
                              "content": {
                                "text": "<string>",
                                "type": "<string>"
                              }
                            }
                          ]
                        }
                      ],
                      "usage": {
                        "prompt_tokens": 123,
                        "completion_tokens": 123,
                        "total_tokens": 123,
                        "total_calls": 123
                      }
                    }
                  },
                  "Popular Special Effects Videos": {
                    "value": {
                      "status": "<string>",
                      "agent_id": "<string>",
                      "async_id": "<string>"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "The request has failed.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "title": "General Translation",
                      "$ref": "#/components/schemas/Error"
      

# --- truncated at 32 KB (161 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/zhipu-ai/refs/heads/main/openapi/zhipu-ai-openapi.json