New AI Provider: GLM (智谱AI) Now Available
Your apps can now use GLM alongside Gemini. OpenAI-compatible format, streaming support, no API key needed.
Another AI Model for Your Apps
We've added a new AI endpoint: `/api/ai/glm` — powered by GLM (智谱AI), one of China's leading AI models.
This means your apps on gapp.so now have access to two AI providers:
- Gemini via
/api/ai/gemini(Google) - GLM via
/api/ai/glm(智谱AI)
Same deal as Gemini: no API key required, no configuration, just works.
Why GLM?
- Strong Chinese language performance — GLM excels at Chinese content generation, making it ideal for bilingual apps
- OpenAI-compatible format — If you've used the OpenAI API before, you already know how to use GLM
- Fast and capable — The default
glm-5model offers strong reasoning and generation quality - Streaming support — Real-time token streaming for responsive UIs
Available Models
| Model | Use Case |
|---|---|
glm-5 | Latest flagship model, strong reasoning (default) |
glm-5-turbo | Faster variant of GLM-5 |
glm-4.7 | Previous generation, still capable |
glm-4.7-flash | Fast and free tier |
To specify a model, add it to your request body:
body: JSON.stringify({
model: 'glm-5', // or any model above
messages: [{ role: 'user', content: 'Hello' }]
})If you don't specify a model, glm-5 is used by default.
How to Use It
Basic Request
async function askGLM(message) {
const response = await fetch('/api/ai/glm', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
messages: [
{ role: 'user', content: message }
]
})
});
const data = await response.json();
return data.choices?.[0]?.message?.content || 'No response';
}
const reply = await askGLM('Tell me about the Great Wall');With System Prompt
async function askGLM(message, systemPrompt) {
const response = await fetch('/api/ai/glm', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'user', content: message }
]
})
});
const data = await response.json();
return data.choices?.[0]?.message?.content;
}
const reply = await askGLM(
'Recommend a dish',
'You are a helpful Chinese cuisine expert. Keep responses concise.'
);Streaming
async function streamGLM(message, onChunk) {
const response = await fetch('/api/ai/glm', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
messages: [{ role: 'user', content: message }],
stream: true
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
for (const line of text.split('\n')) {
if (!line.startsWith('data: ') || line === 'data: [DONE]') continue;
const json = JSON.parse(line.slice(6));
const content = json.choices?.[0]?.delta?.content;
if (content) onChunk(content);
}
}
}
// Usage
streamGLM('Write a short poem', (chunk) => {
process.stdout.write(chunk); // or append to DOM
});Multi-turn Conversation
const messages = [
{ role: 'system', content: 'You are a friendly tutor.' }
];
async function chat(userMessage) {
messages.push({ role: 'user', content: userMessage });
const response = await fetch('/api/ai/glm', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ messages })
});
const data = await response.json();
const reply = data.choices[0].message.content;
messages.push({ role: 'assistant', content: reply });
return reply;
}GLM vs Gemini: When to Use Which
GLM (/api/ai/glm) | Gemini (/api/ai/gemini) | |
|---|---|---|
| Format | OpenAI-compatible (messages) | Google Generative AI format |
| Chinese content | Excellent | Good |
| English content | Good | Excellent |
| Image generation | Not supported | Supported (gemini-3.1-flash-image) |
| Default model | glm-5 | gemini-3-flash-preview |
Quick rule: Use GLM when your app needs strong Chinese language support or when you prefer the OpenAI message format. Use Gemini for image generation or when you want the Google AI ecosystem.
You can also use both in the same app — for example, Gemini for image generation and GLM for Chinese text.
Bring Your Own Key (BYOK)
If you want higher rate limits or to use a specific GLM model, you can add your own API key in Dashboard Settings. Your key is encrypted and stored securely.
Rate Limits
GLM shares the same rate limit quota as Gemini. If you need more, add your own API key (BYOK) for unlimited usage.
Ready to try it? Just point your fetch calls to /api/ai/glm and start building!