How to Use Z.ai (Zhipu) API in Cursor Editor: Setup Custom Endpoint

📌 KEY TAKEAWAYSQuick Technical Reference
Universal Gateway
baseURL: "https://apivale.com/v1"
Supported Ecosystems
Cursor, Claude Code, Cline, Windsurf
Global Billing Rail
Waffo Global Billing (Zero KYC)
Sandbox Quota
$0.20 Developer Credit (No Card Required)
⚡ Quick Setup Generator
CLI & IDE One-Click Configurator

Select your coding tool and target model to generate instant, zero-login proxy configuration commands.

BASH
# Export APIVALE proxy base URL and API key
export ANTHROPIC_BASE_URL="https://apivale.com/v1"
export ANTHROPIC_API_KEY="sk-apivale-your-api-key"

# Launch Claude Code CLI with target model
claude --model infer/glm-5.3

Cursor has quickly become the IDE of choice for developers seeking state-of-the-art AI pair programming. However, developers wanting to leverage Zhipu AI’s flagship glm-5.2 model inside Cursor often hit a brick wall. The official Zhipu developer portal (open.bigmodel.cn and its global brand z.ai) makes it notoriously difficult to generate a standard, compatible API key and configure it as a custom OpenAI endpoint without encountering authorization and routing errors.

In this tutorial, we show you how to configure a custom endpoint in Cursor to call Zhipu models via APIVALE. By routing requests through APIVALE, you bypass the +86 phone registration and mainland bank billing hurdles, allowing you to use GLM-5.2 directly within your IDE in under two minutes.

Quick Start: Cursor API Key Test

To verify if your custom endpoint is ready, you can run a simple cURL test pointing to the APIVALE proxy. Ensure you replace YOUR_APIVALE_KEY with your actual token:

curl https://apivale.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_APIVALE_KEY" \
  -d '{"model": "glm-5.2", "messages": [{"role": "user", "content": "Hello, list 3 programming best practices."}]}'

Direct Z.ai Setup vs. APIVALE Cursor Routing

Attempting to connect Cursor directly to Zhipu’s official endpoint vs. using APIVALE’s unified routing layer yields the following differences:

MetricOfficial Zhipu Custom Endpoint (open.bigmodel.cn)APIVALE Gateway Endpoint (api.z.ai proxy)
Cursor Base URLhttps://open.bigmodel.cn/api/paas/v4/ (Incompatible format)https://apivale.com/v1 (100% OpenAI compatible)
Authentication HeaderCustom JWT Token (Requires SDK generation)Standard Bearer API Key
Ideal Model For CursorManual JSON translation requiredglm-5.2, glm-4-plus mapped automatically
Payment & BillingChinese Bank Cards / Alipay (declines foreign cards)PayPal & Global Credit Cards (see our Z.ai Billing Top-Up & Credit Card Guide)
Latency / Edge RoutingUnoptimized routing from US/EUGlobal CDN edge optimization (~150ms TTFT)

Definition

Cursor Custom Endpoint

A Cursor Custom Endpoint is an override configuration within the Cursor IDE settings that redirects LLM API calls from the default OpenAI server to a third-party reverse proxy or custom gateway while maintaining the standard OpenAI SDK schema. Because official Zhipu developer accounts reject foreign payment cards and enforce domestic identity verification, developers configure APIVALE as a custom endpoint to bypass KYC and recharge balances seamlessly via PayPal (see our step-by-step Z.ai Billing Top-Up & Credit Card Fix Guide).


Step-by-Step Cursor Configuration

Follow this quick guide to set up the Z.ai models in your Cursor editor.

Step 1: Get Your APIVALE Key

  1. Go to APIVALE Gateway and create a free account.
  2. Navigate to your dashboard, generate an API Key, and copy it.

Step 2: Configure Settings in Cursor

  1. Open your Cursor Editor.
  2. Click the gear icon in the top-right corner to open Cursor Settings.
  3. Under the Models tab, scroll down to the OpenAI API section.
  4. Toggle the switch to ON to override the default OpenAI configuration.
  5. In the API Key input box, paste your APIVALE_API_KEY.
  6. Click on Configure Override / Base URL.
  7. Enter the following URL in the input field:
    https://apivale.com/v1
  8. In the model list, make sure to add glm-5.2 and glm-4-plus as custom models.

“A major pain point for developers using third-party APIs in IDEs is header mismatch. Cursor expects a standard Bearer format, whereas Zhipu’s native API requires dynamic JWT authorization. APIVALE translates this seamlessly on the fly.” — Alex Rivera, Senior Cloud Architect, APIVALE


Automation & .cursorrules Implementation

To optimize code-generation results from glm-5.2 inside Cursor, you should define custom rules in your project root using a .cursorrules file. This instructs GLM-5.2 to respond in a format optimized for your stack.

Example .cursorrules for Web Development

Create a file named .cursorrules in your project root:

# GLM-5.2 Cursor Development Directives

- **Response Style**: Provide concise, production-ready code blocks. Avoid long prose explanations.
- **Framework Specifications**: Use TypeScript for Node.js scripts. For UI components, use vanilla Tailwind CSS with strict HTML5 elements.
- **Error Handling**: Every network call or database query MUST be wrapped in a robust try-catch block.
- **Formatting**: Always indent with 2 spaces and use ES6 syntax.

Python Test Script for Custom Proxy Routing

If you also wish to test your endpoint in a python helper script before editing code in Cursor, use this clean template:

import os
import openai
from openai import OpenAIError

# Configure Client pointing to APIVALE Custom Endpoint
client = openai.OpenAI(
    base_url="https://apivale.com/v1",
    api_key=os.environ.get("APIVALE_API_KEY")
)

def query_custom_model():
    try:
        response = client.chat.completions.create(
            model="glm-5.2",
            messages=[
                {"role": "system", "content": "You are a senior code reviewer."},
                {"role": "user", "content": "Review this function for potential leaks: 'def execute(cmd): os.system(cmd)'"}
            ],
            temperature=0.1,
            timeout=15.0
        )
        print("GLM-5.2 Code Review Response:")
        print(response.choices[0].message.content)
    except OpenAIError as e:
        print(f"Error querying custom model endpoint: {e}")

if __name__ == "__main__":
    query_custom_model()

💻 Integrate Z.ai GLM-5.2 in Cursor Instantly

Connect Zhipu models to Cursor or VS Code in seconds without custom JWT SDK auth wrappers. Access GPT-5.5, Claude 4 Sonnet, DeepSeek V4, and GLM-5.2 through APIVALE's standard OpenAI-compatible base URL. Sign up today and get $0.20 free starting credit (+ 50% bonus on 1st top-up)s.

Developer FAQ

Q: Will overriding the OpenAI Base URL in Cursor break my access to default models? A: Yes, if you enter a custom Base URL in the main OpenAI field, Cursor will route all OpenAI model requests there. If you want to use both default models and custom models, we recommend adding APIVALE as a custom OpenAI key and specifying glm-5.2 as an additional model while letting Cursor manage default models natively.

Q: What is the correct OpenAI base URL format for Cursor? A: The standard format is https://apivale.com/v1. Do not add a trailing slash / or append /chat/completions as Cursor appends that automatically.

Q: Do I get billed extra for using custom models in Cursor via APIVALE? A: No. APIVALE actually offers GLM-5.2 at rates significantly below the official console pricing ($0.50/1M input and $2.50/1M output, compared to Zhipu’s official $1.40/$4.40), saving you up to 64% on token usage.

🎁 ZERO-CARD FREE TRIAL ACTIVE
⚡ Slash Coding Agent Token Costs by 80% with APIVALE

Zero credit card required. Register in 10s to claim 100,000 Free Tokens ($0.20) for instant testing in our Web Playground or via Cursor / Claude Code CLI. Test DeepSeek-V4.1, Qwen 3.8, and GLM-5.3 completely free before deciding to recharge!

⚡100,000 Free Starter Tokens (Zero Credit Card Required)
🧪Instant Online & CLI Testing (DeepSeek / Qwen / GLM)
🎁+50% First Deposit Bonus (Deposit $5 → Get $7.50 When Ready)
💳PayPal & Global Cards (Instant 0s Activation, Zero KYC)
✓ Zero KYC • No forced payments • Tokens never expire • Start testing 100% free
Alex Rivera
About Alex Rivera

Alex Rivera is a veteran cloud architect specializing in API routing gateway integrations, custom developer IDE configs, and latency optimization.