How to Use GLM Through OpenRouter and Alternative Providers
Purpose
I want to use GLM models, but Zhipu’s direct service has been unreliable during training cycles. This post shows how to access GLM through alternative providers like OpenRouter.
Why Use Alternative Providers?
The problem with Zhipu’s direct service:
- Long context degraded during training cycles- Service outages without clear communication- Annual subscribers locked into unreliable service- Quantized models served without notificationThe solution: Use alternative providers that offer GLM model access.
A Reddit user confirmed this works: “GLM 5 through other providers seems to work fine. Even openrouter I find pretty good.”
Option 1: OpenRouter
OpenRouter is a unified API that aggregates multiple AI models from different providers.
How to set it up:
- Create an account at openrouter.ai
- Add API credits (pay per token)
- Use the OpenRouter API endpoint
API call example:
import openai
# Configure OpenRouter as base URLclient = openai.OpenAI( base_url="https://openrouter.ai/api/v1", api_key="YOUR_OPENROUTER_API_KEY")
# Use GLM modelresponse = client.chat.completions.create( model="zhipu/glm-4-plus", messages=[ {"role": "user", "content": "Hello, how can you help me?"} ])
print(response.choices[0].message.content)Key points:
- The model name format is
zhipu/glm-4-plus(provider prefix) - Uses standard OpenAI SDK interface
- Pay only for what you use
- No annual commitment
Option 2: Alibaba Coding Plan
Alibaba’s coding platform includes GLM access as part of their subscription.
A user reported: “I’m using it through alibaba coding plan and its great.”
Benefits:
- Bundled with Alibaba Cloud services
- Optimized for coding tasks
- Subscription-based (predictable costs)
- Good integration with Alibaba ecosystem
Option 3: Self-Hosting
GLM is open-source, so you can run it yourself.
Requirements:
- Download weights from HuggingFace- GPU with significant VRAM (for large models)- Technical skill to deploy and maintain- No API costs, but infrastructure costsThis gives you full control and privacy, but requires hardware investment.
Provider Comparison
Provider Pricing Flexibility Best For─────────────────────────────────────────────────────Zhipu Direct Subscription Limited Official supportOpenRouter Pay per token High Testing, flexibilityAlibaba Subscription Medium Coding workflowsSelf-host Hardware cost Full Privacy, high volumeCommon Issues
Issue: Model names differ between providers
The same model might be called:
glm-4(Zhipu direct)zhipu/glm-4-plus(OpenRouter)- Different naming in Alibaba
Solution: Check the provider’s documentation for exact model identifiers.
Issue: Different context limits
Some providers may limit context differently than Zhipu direct.
Solution: Verify the context window with your chosen provider before committing.
Issue: Feature availability
Not all providers support all GLM variants or features (function calling, vision).
Solution: Confirm specific features are supported before building dependencies.
Using with LangChain
If you use LangChain, integrating OpenRouter is straightforward:
from langchain_openai import ChatOpenAI
# OpenRouter with LangChainllm = ChatOpenAI( model="zhipu/glm-4-plus", openai_api_base="https://openrouter.ai/api/v1", openai_api_key="YOUR_OPENROUTER_API_KEY")
response = llm.invoke("What is the capital of France?")print(response.content)This approach works with any LangChain-based application.
Summary
In this post, I showed how to access GLM through alternative providers. The key point is that OpenRouter and other providers let you use GLM models even when Zhipu’s direct service has issues.
The main options are:
- OpenRouter for pay-per-token flexibility
- Alibaba Coding Plan for coding-focused subscriptions
- Self-hosting for full control
Using alternative providers gives you redundancy and flexibility that annual subscriptions don’t offer.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments