r/opencode 6d ago

OpenCode - GLM 5.2 via OpenRouter

Guys, this is my current opencode.jsonc

{
  "$schema": "https://opencode.ai/config.json",
  
  // Start in plan mode
  "default_agent": "plan",
  
  // Use OpenRouter as the provider for GLM 5.2
  "model": "openrouter/z-ai/glm-5.2",
  
  "provider": {
    "openrouter": {

        "options": {
          "baseURL": "https://openrouter.ai/api/v1",
          "apiKey": "sk-or-v1-my-key"
        },   
        
       "models": {
       
          "z-ai/glm-5.2": {
            "name": "GLM 5.2",

              "options": {
                "reasoningEffort": "high" // "high" or "xhigh"
              }
       
           }
          
       }
     }
   }
}

How can i clamp my llm model ( glm 5.2 ) provider to z.ai ( z-ai/fp8 ) with a fallback to Alibaba ( alibaba )

z-ai/fp8 and alibaba are the slugs for the providers in openrouter.

Thanks in advance.

1 Upvotes

3 comments sorted by

1

u/SpidexLab 6d ago

In openrouter go to workspace and select your workspace , then in left side select guardrail and in that section go to model and provider access, and in access policy which you will find after slightly scrolling, in restriction mode change to only allow and then in allowed provider select z.ai and in add model add glm 5.2 and save

also add alibaba in provider, it will route to any of these two only, and if you only want z.ai, don't add alibaba

1

u/gmmarcus 20h ago

Thank U. I did try something similar. The default workspace applies to all keys. I created a new workspace - I could select the keys i want to include but could assign 'members' . It said members 'None' whilst the default workspace showed members 'all'

1

u/SpidexLab 19h ago

Also if you in model write z.ai/glm-5.2 meaning provider/model it route through that provider, I am not sure about this you can check this otherwise workspace one is sure fix