Skip to main content
n8n lets you orchestrate API workflows without code. This guide shows how to call Z.AI’s GLM models inside any n8n workflow using the OpenAI node.
When you are subscribed to the GLM Coding Plan, switch the base URL to https://api.z.ai/api/coding/paas/v4 instead of the general API endpoint used below.

Prerequisites

  • An n8n deployment (desktop, self-hosted, or n8n Cloud)
  • Basic familiarity with n8n nodes

QuickStart

1

Get API Key

2

Configure n8n Credentials

  • In the n8n UI, go to Credentials β†’ + New.
  • Select OpenAI (use the OpenAI node to call Z.AI’s Inference API).
Description
  • Configure the credential:
    • Name: ZAI Account
    • API KEY: YOUR_ZAI_API_KEY
    • Base URL: https://api.z.ai/api/paas/v4
  • If you use the GLM Coding Plan, use the https://api.z.ai/api/coding/paas/v4 as the base URL.
  • Save the credential and will auto test the credential to make sure it works.
Description
3

Create an n8n Workflow

  • In the n8n UI, go to Workflows β†’ + New.
  • Add openai chat node in your workflow, and select ZAI Account as the credential.
  • Configure the openai chat node:
    • Model: glm-4.6
Description
4

Run the Workflow

  • Click Execute Workflow to run the workflow.
  • The response will be available in the Output tab.
Description

Troubleshooting

Issue: Receiving invalid api key errorSolutions:
  1. Confirm the api key is correctly copied
  2. Confirm the api key has sufficient balance
Issue: connection timeoutSolutions:
  1. Check network connection
  2. Confirm firewall settings
  3. Verify the base URL is correct
  4. Increase timeout settings