Skip to content

Instantly share code, notes, and snippets.

@olafgeibig
Last active September 19, 2025 04:09
Show Gist options
  • Select an option

  • Save olafgeibig/925ed73f10a5b99d891c0185580f4e42 to your computer and use it in GitHub Desktop.

Select an option

Save olafgeibig/925ed73f10a5b99d891c0185580f4e42 to your computer and use it in GitHub Desktop.
Z.ai subscription with opencode

Z.ai subscription with opencode

Now Z.ai has an official solution to use the package. See below.

Create a custom provider

First we need to create a custom provider for the Z.ai anthropic API. Follow the instructions for adding a custom provider to opencode.

  • Name it zai-anthropic
  • Enter your API-key

Configure the custom-provider

Edit opencode.json and add this:

    "provider": {
        "zai-anthropic": {
            "npm": "@ai-sdk/anthropic",
            "options": {
                "baseURL": "https://api.z.ai/api/anthropic/v1"
            },
            "models": {
                "glm-4.5": {
                    "name": "glm-4.5"
                }
            }
        }

Make this model default if you wish:

    "model": "zai-anthropic/glm-4.5",

Official solution from Z.ai

Now there is the official solution to support opencode and others. I switched and it works perfectly. Great job Z.ai.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "zai": {
      "options": {
        "baseURL": "https://api.z.ai/api/coding/paas/v4"
      }
    }
  }
}
@nathabonfim59
Copy link

They are running a promo for $36 for the whole year. A WHOLE FREAKING YEAR!! I don't even know what's going on at this point.

The bigger models even support vision, but I think it's restricted to the Pro/Max plan.

They also released the "official" rate limits, but from what I've tested, it's not being currently enforced.

Image
image
image

https://z.ai/subscribe

Note

Full transparency, THIS IS an affiliate link. I think I get less than $1 worth of inference for each subscription.
It won't cost anything more for you, and we both get something out of it. ;)
If not, just copy the link https://z.ai/subscribe and you're good to go.

I think @olafgeibig should put his one up top, he was the one who created this gist, it's only fair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment