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.

Revisions

  1. olafgeibig revised this gist Sep 10, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Z.ai subscription with opencode
    I do not guarantee that this is actually billed on your subscription inclusive volume and not as API consumption. Since Z.ai has no near realtime API usage information, I could not check it. Update: after 2 days of using it, no extra money was decucted from my credits. Guess tht means it works.
    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](https://opencode.ai/docs/providers/#custom-provider) to opencode.
  2. olafgeibig renamed this gist Sep 10, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. olafgeibig renamed this gist Sep 10, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. olafgeibig revised this gist Sep 10, 2025. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    ## 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.

    ```json
    {
    "$schema": "https://opencode.ai/config.json",
    "provider": {
    "zai": {
    "options": {
    "baseURL": "https://api.z.ai/api/coding/paas/v4"
    }
    }
    }
    }
    ```
  5. olafgeibig revised this gist Sep 3, 2025. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,8 @@
    # Z.ai subscription with opencode
    I do not guarantee that this is actually billed on your subscription inclusive volume and not as API consumption. Since Z.ai has no near realtime API usage information, I could not check it.
    I do not guarantee that this is actually billed on your subscription inclusive volume and not as API consumption. Since Z.ai has no near realtime API usage information, I could not check it. Update: after 2 days of using it, no extra money was decucted from my credits. Guess tht means it works.

    ## 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](https://opencode.ai/docs/providers/#custom-provider) to opencode.
    First we need to create a custom provider for the Z.ai anthropic API. Follow the instructions for adding a [custom provider](https://opencode.ai/docs/providers/#custom-provider) to opencode.
    - Name it `zai-anthropic`
    - Enter your API-key

  6. olafgeibig revised this gist Sep 2, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ I do not guarantee that this is actually billed on your subscription inclusive v

    ## 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](https://opencode.ai/docs/providers/#custom-provider)
    Follow the instructions for adding a [custom provider](https://opencode.ai/docs/providers/#custom-provider) to opencode.
    - Name it `zai-anthropic`
    - Enter your API-key

  7. olafgeibig revised this gist Sep 2, 2025. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # Z.ai subscription with opencode
    I do not guarantee that this is actually billed on your subscription inclusive volume and not as API consumption. Since Z.ai has no near realtime API usage information, I could not check it.

    ## Create a custom provider
    First we need to create a custom provider for the Z.ai anthropic api
  8. olafgeibig created this gist Sep 2, 2025.
    28 changes: 28 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    # Z.ai subscription with opencode

    ## 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](https://opencode.ai/docs/providers/#custom-provider)
    - Name it `zai-anthropic`
    - Enter your API-key

    ## Configure the custom-provider
    Edit opencode.json and add this:
    ```json
    "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:
    ```json
    "model": "zai-anthropic/glm-4.5",
    ```