Integrations
Using via OpenRouter
Access LLMBase models through OpenRouter's unified API gateway.
Updated
OpenRouter is a unified API gateway that routes requests across hundreds of AI providers. LLMBase models are listed on OpenRouter, so you can access them alongside models from OpenAI, Anthropic, Google, and others — using a single OpenRouter API key.
Endpoint
Use OpenRouter’s base URL instead of LLMBase’s:
https://openrouter.ai/api/v1
Model IDs on OpenRouter
OpenRouter model IDs are the same as LLMBase’s unified model IDs:
| LLMBase model | OpenRouter model ID |
|---|---|
| GLM-5 | zai-org/glm-5 |
| GLM-4 | zai-org/glm-4 |
Quick example
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://openrouter.ai/api/v1",
apiKey: process.env.OPENROUTER_API_KEY,
});
const response = await client.chat.completions.create({
model: "zai-org/glm-5",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
OpenRouter-specific headers
OpenRouter recommends including two optional headers for analytics and abuse prevention:
const client = new OpenAI({
baseURL: "https://openrouter.ai/api/v1",
apiKey: process.env.OPENROUTER_API_KEY,
defaultHeaders: {
"HTTP-Referer": "https://yourapp.com", // your site URL
"X-Title": "Your App Name", // shown in OpenRouter dashboard
},
});
curl
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "HTTP-Referer: https://yourapp.com" \
-H "X-Title: Your App" \
-H "Content-Type: application/json" \
-d '{
"model": "zai-org/glm-5",
"messages": [{ "role": "user", "content": "Hello!" }]
}'
When to use OpenRouter vs direct
Direct (api.llmbase.ai) | Via OpenRouter | |
|---|---|---|
| Latency | Lower — one fewer hop | Slightly higher |
| Billing | Billed directly by LLMBase | Billed by OpenRouter |
| Key management | Separate LLMBase key | Single key for all providers |
| Model switching | LLMBase models only | Any OpenRouter model |
| Rate limits | LLMBase limits | OpenRouter limits |
Use the direct API when you only need LLMBase models and want the lowest latency. Use OpenRouter when you want a single key and the ability to swap providers without changing code.