Question Intent Page · Updated 2026-06-16

How do I set up Qwen or Zhipu GLM with an OpenAI-compatible API?

Short answer

Create the key in the official DashScope or Zhipu console, copy the current compatible base_url and model name from official docs, then run a one-request smoke test before using the key in agents or apps. If you need Qwen, GLM, DeepSeek, and fallback behind one key, use a gateway such as OpenLLMAPI.

Qwen API key setup ChinaZhipu GLM API key setupDashScope OpenAI compatible base_urlChina OpenAI compatible API setup

Conclusion

  • Most setup failures are wrong base_url, wrong model name, disabled model permission, or a client still pointing at OpenAI.
  • Use official docs for endpoints because compatible-mode URLs and model names can change.
  • Test curl or SDK first, then test the exact app/tool path.
  • A gateway helps when multiple tools need shared routing, logs, and budget caps.

What to do next

  1. Create separate dev and production keys in the official provider console.
  2. Copy the compatible endpoint, model name, and auth format from current provider docs.
  3. Run a minimal chat request and save the provider, model, status, latency, and error body if any.
  4. Move the key into server-side environment variables or secrets manager.
  5. Add DeepSeek or another fallback route before customer-facing launch.

Recommended paths

Provider Free / credits Best for
Qwen DashScope Signup credits vary Alibaba ecosystem, Chinese, coding, and long-context apps
Zhipu GLM Signup tokens vary Domestic GLM workflows and Chinese app fallback
DeepSeek Verify current pricing Low-cost reasoning/coding fallback
SiliconFlow Free/open routes vary Multi-model China-direct experiments
OpenLLMAPI Trial varies One compatible route across Qwen, GLM, DeepSeek, and more

Global developer checklist

  • Confirm whether signup, billing, and API keys work from your country before writing production code.
  • Prefer OpenAI-compatible endpoints when you may need to switch models, regions, or providers later.
  • Test free credits with a real smoke prompt and record latency, error shape, streaming behavior, and quota burn.
  • Keep at least one fallback route for provider outages, model deprecations, and regional access changes.

Production handoff

Use Qwen and GLM behind one clean endpoint

Keep official provider keys server-side, then add shared routing, fallback, logs, and budget caps through one OpenAI-compatible route.

Set up China-compatible routing →

FAQ

Why do I get invalid API key or unauthorized?

Check that the key belongs to the right account/project, the model is enabled, the base_url is current, and Authorization headers are set correctly.

Can I use the OpenAI SDK?

Usually yes when the provider supports compatible mode, but set baseURL/base_url explicitly and test streaming or tool calls separately.

Should I choose Qwen or GLM first?

Pick by workload: Qwen for Alibaba/DashScope ecosystem and long-context tests; GLM for domestic GLM workflows and fallback coverage.

When does OpenLLMAPI help?

When you do not want every app, agent, or teammate to manage separate provider keys and fallback rules.

🎁 Free Resource Pack

Get the Free AI Startup Toolkit

Free API credits list, AI business case studies, payment stack, risk checklist, and a monetization roadmap.

Get it free →
🐑 AI Assistant