BigModel API Step One: Keys, Requests, and Prompt Placement
2026-11-02 · Prompt Tutorials
Many developers get a GLM API key and then stall at the first step: how to format the request, whether prompts belong in system or user, and how to enable thinking mode. This article walks through the chain in real calling order — create the key, send the request, place the prompts — with copy-paste templates at each stage.
1. Getting the Key: BigModel Console Basics
Log in to the BigModel open platform (bigmodel.cn) console and create a key on the "API Keys" page. Practical tips:
- The key is shown in full only once at creation. Copy it immediately into a local environment variable; never hardcode it;
- Create separate keys per project so you can trace usage per key on the billing page;
- Load it via an environment variable in local development:
bash export ZHIPUAI_API_KEY="your-key"
Billing, free tiers, and per-model pricing change over time — check the official pages before calling.
2. The First Request: Endpoint and Payload
The BigModel API follows the widely used chat/completions style. Verify the chain with curl first:
bash
curl -s https://open.bigmodel.cn/api/paas/v4/chat/completions \
-H "Authorization: Bearer $ZHIPUAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4.6",
"messages": [
{"role": "user", "content": "Explain recursion in one sentence"}
]
}'
Common pitfalls: the Authorization header needs the Bearer prefix; the model field must match a model name confirmed in the model marketplace — GLM versions iterate quickly, so check the official docs for current names; in Python, both the official SDK and OpenAI-compatible clients work by pointing base_url at BigModel.
3. Where Prompts Go: system vs. user
GLM responds to prompt placement the way mainstream models do: system holds long-term rules and persona; user holds the current task input. A common mistake is putting rules like "act as a senior translator, output only the translation" into user — repeated on every call, and less stable in priority than system.
Here is a copyable system + user template for structured Chinese text processing:
【system】
You are a rigorous Chinese text editor. Rules:
1. Fix only typos, punctuation, and obvious grammar issues; do not alter meaning or tone;
2. Output only the corrected text — no explanations, prefixes, or Markdown wrappers;
3. If no changes are needed, return the input as-is.
【user】
{{text_to_process}}
For reasoning-heavy tasks, pair this with GLM's thinking mode. The switch is typically a request parameter (parameter names differ across versions — see the official API docs):
【system】
You are an algorithm engineer. Upon receiving a problem, first analyze edge cases and time complexity in your thinking, then produce the final answer. The final answer must be Python code including the function signature, complete logic, and one test case. Output nothing unrelated to the problem.
【user】
Problem: {{problem_statement}}
Key point: writing "separate reasoning from the final answer" into system makes output structure far more stable under thinking mode. Coding is a strength of the GLM series — explicitly specifying language and test cases in the template meaningfully cuts rework.
4. Multimodal and Beyond: GLM-4V and Parameter Tips
For image understanding, use the GLM-4V series with content as an array, passing images by URL (field format per official docs). A copyable vision QA template:
【system】
You are an image moderation assistant. For each image, check these dimensions and output JSON:
{"has_text": bool, "text_summary": str, "contains_person": bool, "risk_level": "low|medium|high"}
Output JSON only, no extra text.
【user】
(attached image) Analyze this image per the rules.
Three parameter tips: lower temperature for factual and coding tasks; give max_tokens ample headroom when thinking is on, or truncated reasoning degrades answers; enable streaming (stream) for interactive UIs — long reasoning feels much less sluggish.
5. How Differences vs. GPT/Claude/Kimi/DeepSeek Affect Your Calls
At the API layer, GLM matches the chat/completions style of GPT, Claude, Kimi, and DeepSeek, so migration cost is mostly in prompt habits: GLM's strong Chinese-language training means Chinese instructions follow reliably, and few scenarios require rewriting prompts in English. DeepSeek users will find the thinking-parameter approach familiar. The Coding Plan targets high-frequency coding calls — when wiring up Claude Code and similar tools, follow the official integration docs. On the open-weights side, GLM series weights are available for local deployment; your API prompt templates can be reused as-is for local deployments — just swap the endpoint.
The first successful call is just the start. Turn this flow into your own scaffolding: keys in environment variables, system templates in a library, one key per project for cost tracking. After that, whether it's GLM-4V multimodal or thinking mode on hard problems, you're only swapping the model name and prompt.
本文为使用方法整理,内容选自网上公开资料,供参考;本站为非官方资讯站,产品能力以官方页面为准。