Zhipu AI Paas API

The Paas API from Zhipu AI — 10 operation(s) for paas.

OpenAPI Specification

zhipu-ai-paas-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Z.AI Agents Paas 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: user_feedback@z.ai
servers:
- url: https://api.z.ai/api
  description: Production server
security:
- bearerAuth: []
tags:
- name: Paas
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'
      tags:
      - Paas
  /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.


        Vidu: 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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
  /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'
      tags:
      - Paas
components:
  schemas:
    ViduText2VideoRequest:
      allOf:
      - type: object
        properties:
          model:
            type: string
            description: The model code to be called.
            enum:
            - viduq1-text
          prompt:
            type: string
            description: Text description of the video, maximum input length of 512 characters.
          style:
            type: string
            description: 'Style

              Default: `general`

              Optional values: `general` , `anime`

              - `general`: General style, can be controlled using prompts to define the style.

              - `anime`: Anime style, optimized for anime-specific visuals. The style can be controlled using different anime-themed prompts.'
            enum:
            - general
            - anime
          duration:
            type: integer
            description: 'Video duration parameter.

              Default: `5` , Optional: `5`.'
            example: 5
            enum:
            - 5
          aspect_ratio:
            type: string
            description: 'Aspect ratio

              Default: `16:9`, Optional values: `16:9`, `9:16`, `1:1`'
            example: '16:9'
            enum:
            - '16:9'
            - '9:16'
            - '1:1'
          size:
            type: string
            description: 'Resolution parameter

              Default: `1920x1080`, Optional: `1920x1080`'
            example: 1920x1080
            enum:
            - 1920x1080
          movement_amplitude:
            type: string
            description: 'Motion amplitude

              Default: `auto` , Optional values:  `auto` ,`small` ,`medium` ,`large`'
            example: auto
            enum:
            - auto
            - small
            - medium
            - large
        required:
        - model
        - prompt
      - $ref: '#/components/schemas/VideoCommonRequest'
    WebSearchToolSchema:
      type: object
      title: Web Search
      properties:
        type:
          type: string
          default: web_search
          enum:
          - web_search
        web_search:
          $ref: '#/components/schemas/WebSearchObject'
      required:
      - type
      - web_search
      additionalProperties: false
    AudioTranscriptionResponse:
      type: object
      properties:
        id:
          type: string
          description: Task ID
        created:
          type: integer
          format: int64
          description: Request creation time, as a `Unix` timestamp in seconds.
        request_id:
          type: string
          description: Passed by the client, must be unique. A unique identifier to distinguish each request. If not provided by the client, the platform will generate one by default.
        model:
          type: string
          description: Model name
        text:
          type: string
          description: The complete transcribed content of the audio.
    RetrievalToolSchema:
      type: object
      title: Retrieval
      properties:
        type:
          type: string
          default: retrieval
          enum:
          - retrieval
        retrieval:
          $ref: '#/components/schemas/RetrievalObject'
      required:
      - type
      - retrieval
      additionalProperties: false
    Error:
      required:
      - code
      - message
      type: object
      description: The request has failed.
      properties:
        code:
          type: integer
          format: int32
          description: Error code.
        message:
          type: string
          description: Error message.
    AsyncVideoGenerationResponse:
      type: object
      properties:
        model:
          type: string
          description: Model name.
        task_status:
          type: string
          description: 'Processing status, `PROCESSING` (processing), `SUCCESS` (success), `FAIL` (failure). Note: Processing status needs to be obtained via query.'
        video_result:
          type: array
          description: Video generation results.
          items:
            type: object
            properties:
              url:
                type: string
                description: Video URL.
              cover_image_url:
                type: string
                description: Video cover URL.
        request_id:
          type: string
          description: Task number submitted by the user during the client request or generated by the platform.
    RetrievalObject:
      type: object
      properties:
        knowledge_id:
          type: string
          description: Knowledge base ID, created or obtained from the platform
        prompt_template:
          type: string
          description: 'Prompt template for requesting the model, a custom request template containing placeholders `{{ knowledge }}` and `{{ question }}`. Default template: Search for the answer to the question `{{question}}` in the document `{{ knowledge }}`. If an answer is found, respond only using statements from the document; if no answer is found, use your own knowledge to answer and inform the user that the information is not from the document. Do not repeat the question, start the answer directly.'
      required:
      - knowledge_id
    LayoutDetail:
      type: object
      description: Layout detail element
      properties:
        index:
          type: integer
          description: Element index
          example: 1
        label:
          type: string
          description: 'Element type: image for images, text for text content, formula for inline formulas, table for tables'
          enum:
          - image
          - text
          - formula
          - table
          example: text
        bbox_2d:
          type: array
          description: Normalized element coordinates [x1,y1,x2,y2]
          items:
            type: number
            minimum: 0
            maximum: 1
          minItems: 4
          maxItems: 4
          example:
          - 0.1
          - 0.1
          - 0.5
          - 0.3
        content:
          type: string
          description: Element content (text / image URL / table HTML)
          example: This is the content of the element
        height:
          type: integer
          description: Page height
          example: 800
        width:
          type: integer
          description: Page width
          example: 600
      required:
      - index
      - label
    DataInfo:
      type: object
      description: Document basic information
      properties:
        num_pages:
          type: integer
          description: Total number of document pages
          example: 5
        pages:
          type: array
          description: Document page count information
          items:
            $ref: '#/components/schemas/PageInfo'
      required:
      - num_pages
    TokenizerRequest:
      type: object
      required:
      - model
      - messages
      properties:
        model:
          type: string
          description: The model code to be called.
          example: glm-4.6
          default: glm-4.6
          enum:
          - glm-4.6
          - glm-4.6v
          - glm-4.5
        messages:
          type: array
          description: 'The current conversation message list as the model’s prompt input, provided in JSON array format, e.g.,`{“role”: “user”, “content”: “Hello”}`. Possible message types include system messages, user messages. Note: The input must not consist of system or assistant messages only.'
          items:
            oneOf:
            - title: User Message
              type: object
              properties:
                role:
                  type: string
                  enum:
                  - user
                  description: Role of the message author
                  default: user
                content:
                  oneOf:
                  - type: array
                    description: Multimodal message content, supports text, images, video, file
                    items:
                      $ref: '#/components/schemas/VisionMultimodalContentItem'
                  - type: string
                    description: Text message content (can switch to multimodal message above)
                    example: What opportunities and challenges will the Chinese large model industry face in 2025?
              required:
              - role
              - content
            - title: System Message
              type: object
              properties:
                role:
                  type: string
                  enum:
                  - system
                  description: Role of the message author
                  default: system
                content:
                  oneOf:
                  - type: string
                    description: Message text content
                    example: You are a helpful assistant.
              required:
              - role
              - content
            - title: Assistant Message
              type: object
              description: Can include tool calls
              properties:
                role:
                  type: string
                  enum:
                  - assistant
                  description: Role of the message author
                  default: assistant
                content:
                  oneOf:
                  - type: string
                    description: Text message content
                    example: I'll help you with that analysis.
              required:
              - role
          minItems: 1
        tools:
          type: array
          description: List of tools the model can call. Supports up to `128` functions.
          anyOf:
          - items:
              $ref: '#/components/schemas/FunctionToolSchema'
        request_id:
          type: string
          description: Passed by the client, must be unique. If empty, it will be generated by default.
        user_id:
          type: string
          description: Unique `ID` of the end user
    ImageGenerationResponse:
      type: object
      properties:
        created:
          type: integer
          example: 1760335349
          description: Request creation time, in `Unix` timestamp format, unit is seconds.
        data:
          type: array
          description: Array, containing the generated image `URL`. Currently, the array only contains one image.
          items:
            type: object
            properties:
              url:
                type: string
                description: Image link. The temporary link expires after `30` days, please store it promptly.
            required:
            - url
        content_filter:
          type: array
          description: Array, containing content safety related information.
          items:
            type: object
            properties:
              role:
                type: string
                description: Safety enforcement stage, including `role = assistant` model inference, `role = user` user input, `role = history` historical context.
                enum:
                - assistant
                - user
                - history
              level:
                type: integer
                description: Severity level `level 0-3`, `level 0` is most severe, `3` is least severe.
                minimum: 0
                maximum: 3
    CogVideoX3Request:
      allOf:
      - type: object
        properties:
          model:
            type: string
            description: The model code to be called.
            enum:
            - cogvideox-3
          prompt:
            type: string
            description: Text description of the video, maximum input length of 512 characters. Either image_url or prompt must be provided, or both.
          quality:
            type: string
            description: "Output mode, default is `speed`.\n- `quality`: Prioritizes quality, higher generation quality. \n- `speed`: Prioritizes speed, faster generation time, relatively lower quality."
            example: speed
            enum:
            - speed
            - quality
          with_audio:
            type: boolean
            description: 'Whether to generate AI sound effects. Default: `false` (no sound effects).'
            example: false
          image_url:
            type: array
            description: 'Provide an image based on which content will be generated. If this parameter is passed, the system will operate based on this image. Supports passing images via URL or Base64 encoding. Image requirements: images support `.png`, `.jpeg`, `.jpg` formats; image size: no more than `5M`. Either image_url and prompt can be used, or both can be passed simultaneously.

              First and last frames: supports inputting two images. The first uploaded image is regarded as the first frame, and the second image is regarded as the last frame. The model will generate the video based on the images passed in this parameter.

              First and last frame mode only supports `speed` mode'
            items:
              oneOf:
              - title: Image URL
                type: string
                format: uri
                example: https://example.com/image.png
              - title: Base64 Encoded Image
                type: string
                format: byte
                example: data:image/png;base64, XXX
          size:
            type: string
            description: 'Default value: if not specified, the short side of the generated video is 1080 by default, and the long side is determined according to the original image ratio. Maximum support for 4K resolution. Resolution options: "1280x720", "720x1280", "1024x1024", "1080x1920", "2048x1080", "3840x2160"'
            example: 1920x1080
            enum:
            - 1280x720
            - 720x1280
            - 1024x1024
            - 1920x1080
            - 1080x1920
            - 2048x1080
            - 3840x2160
          fps:
            type: integer
            description: 'Video frame rate (FPS), optional values are `30` or `60`. Default: `30`.'
            example: 30
            enum:
            - 30
            - 60
        

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