Skip to content
archived Visibility internal Owner erik@uvilo.com Approver _ Created _ Updated _

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.

See: OpenRouter Requirements


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:

endpoints:
  # ... existing endpoints ...
  custom:
    - name: "OpenRouter"
      apiKey: "${OPENROUTER_KEY}"
      baseURL: "https://openrouter.ai/api/v1"
      models:
        default: ["z-ai/glm-5-turbo"]
        fetch: true
      titleConvo: true
      titleModel: "z-ai/glm-5-turbo"
      dropParams: ["stop"]
      modelDisplayLabel: "OpenRouter"

Key configuration notes

FieldValueReason
apiKey${OPENROUTER_KEY}Must NOT be OPENROUTER_API_KEY — that name overrides the OpenAI endpoint
baseURLhttps://openrouter.ai/api/v1OpenRouter’s OpenAI-compatible API endpoint
models.default["z-ai/glm-5-turbo"]Pre-selected model; the first to enable
models.fetchtrueDynamically fetches all available models from OpenRouter
titleConvotrueAuto-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

  1. Stage the updated config: git add Forge/Configs/LibreChat_Service/librechat.yaml
  2. Commit: git commit -m "feat: add OpenRouter custom endpoint with z-ai/glm-5-turbo"
  3. Push the branch

Step 3: Deploy the config

LibreChat reads librechat.yaml at deploy time only — a restart is NOT sufficient.

  1. Copy the updated config to the deployed location:
    cp /workspace/erik/uvilo-os/Forge/Configs/LibreChat_Service/librechat.yaml /workspace/librechat/
  2. Redeploy LibreChat:
    railway redeploy --service LibreChat

Step 4: Verify the integration

  1. Reload the browser and start a new conversation
  2. Check the endpoint selector — “OpenRouter” should appear as a selectable endpoint
  3. Select OpenRouterz-ai/glm-5-turbo should be the default model
  4. Browse models — the model dropdown should show all available OpenRouter models (fetched dynamically)
  5. Send a test message — confirm a response is received from GLM-5 Turbo
  6. Check the OpenRouter dashboard at openrouter.ai/activity — the request should appear with token usage and cost

Step 5: Troubleshoot (if needed)

SymptomLikely causeFix
OpenRouter not in endpoint listConfig not deployed or YAML syntax errorCheck /workspace/librechat/librechat.yaml is updated; check deploy logs for parse errors
”Invalid API key” errorOPENROUTER_KEY env var not set or wrong valueVerify in Railway dashboard → LibreChat service → Variables
No models in dropdownfetch: true missing or OpenRouter API unreachableConfirm the config has fetch: true under models; check deploy logs
Model errors / 403The stop param or unsupported params being sentEnsure dropParams: ["stop"] is set
OpenAI endpoint brokenUsed OPENROUTER_API_KEY as env var nameRename 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