OpenRouter Spec
Overview
This spec describes how to add OpenRouter as a custom endpoint in LibreChat, configure the first model (z-ai/glm-5-turbo), deploy the changes, and verify the integration works end-to-end.
Step 1: Edit librechat.yaml
The source-of-truth config lives at Forge/Configs/LibreChat_Service/librechat.yaml in the uvilo-os repo.
Add an OpenRouter entry under endpoints.custom. This block should be placed alongside existing endpoint configurations:
Key configuration notes
| Field | Value | Reason |
|---|---|---|
apiKey | ${OPENROUTER_KEY} | Must NOT be OPENROUTER_API_KEY — that name overrides the OpenAI endpoint |
baseURL | https://openrouter.ai/api/v1 | OpenRouter’s OpenAI-compatible API endpoint |
models.default | ["z-ai/glm-5-turbo"] | Pre-selected model; the first to enable |
models.fetch | true | Dynamically fetches all available models from OpenRouter |
titleConvo | true | Auto-generates conversation titles |
titleModel | "z-ai/glm-5-turbo" | Uses GLM-5 Turbo for title generation (fast, cheap) |
dropParams | ["stop"] | OpenRouter models use varied stop tokens; sending stop can cause errors |
modelDisplayLabel | "OpenRouter" | Display name in the LibreChat UI endpoint selector |
Step 2: Commit the config change
- Stage the updated config:
git add Forge/Configs/LibreChat_Service/librechat.yaml - Commit:
git commit -m "feat: add OpenRouter custom endpoint with z-ai/glm-5-turbo" - Push the branch
Step 3: Deploy the config
LibreChat reads librechat.yaml at deploy time only — a restart is NOT sufficient.
- Copy the updated config to the deployed location:
- Redeploy LibreChat:
Step 4: Verify the integration
- Reload the browser and start a new conversation
- Check the endpoint selector — “OpenRouter” should appear as a selectable endpoint
- Select OpenRouter —
z-ai/glm-5-turboshould be the default model - Browse models — the model dropdown should show all available OpenRouter models (fetched dynamically)
- Send a test message — confirm a response is received from GLM-5 Turbo
- Check the OpenRouter dashboard at openrouter.ai/activity — the request should appear with token usage and cost
Step 5: Troubleshoot (if needed)
| Symptom | Likely cause | Fix |
|---|---|---|
| OpenRouter not in endpoint list | Config not deployed or YAML syntax error | Check /workspace/librechat/librechat.yaml is updated; check deploy logs for parse errors |
| ”Invalid API key” error | OPENROUTER_KEY env var not set or wrong value | Verify in Railway dashboard → LibreChat service → Variables |
| No models in dropdown | fetch: true missing or OpenRouter API unreachable | Confirm the config has fetch: true under models; check deploy logs |
| Model errors / 403 | The stop param or unsupported params being sent | Ensure dropParams: ["stop"] is set |
| OpenAI endpoint broken | Used OPENROUTER_API_KEY as env var name | Rename to OPENROUTER_KEY — the _API_KEY suffix conflicts with OpenAI |
About GLM-5 Turbo
GLM-5 Turbo (z-ai/glm-5-turbo) is Z.ai’s model optimized for agent-driven workflows:
- Speed: 200+ tokens per second throughput
- Agent optimization: improved instruction decomposition, tool use, and stability across long execution chains
- Pricing: $0.96/M input tokens, $3.20/M output tokens
- Reasoning: supports reasoning-enabled inference with step-by-step thinking