Skip to content

Add Support for the new Z.AI Subscription plans #2383

Closed

Description

@shekohex

Recently z.ai announced monthly plans: https://z.ai/subscribe and they have support for Claude Code https://docs.z.ai/scenario-example/develop-tools/claude

I've tried to actually do something similar in Opencode v.0.6.3 and there is something wrong I'm doing somewhere, so Here is the steps I did:

  1. run opencode auth add and picked others then added the endpoint to be https://api.z.ai/api/anthropic and added an API Key.
  2. Added zai into the providers section in the opencode.json like the following:
 "provider": {
    "zai": {
      "name": "Z.AI",
      "npm": "@ai-sdk/anthropic",
      "options": {
        "baseURL": "https://api.z.ai/api/anthropic"
      },
      "models": {
        "glm-4.5-air": {
          "id": "glm-4.5-air",
          "name": "GLM-4.5-Air",
          "attachment": false,
          "reasoning": true,
          "temperature": true,
          "tool_call": true,
          "release_date": "2025-07-28",
          "cost": {
            "input": 0.2,
            "output": 1.1,
            "cache_read": 0.03,
            "cache_write": 0
          },
          "limit": {
            "context": 131072,
            "output": 98304
          }
        },
        "glm-4.5": {
          "id": "glm-4.5",
          "name": "GLM-4.5",
          "attachment": false,
          "reasoning": true,
          "temperature": true,
          "tool_call": true,
          "release_date": "2025-07-28",
          "cost": {
            "input": 0.6,
            "output": 2.2,
            "cache_read": 0.11,
            "cache_write": 0
          },
          "limit": {
            "context": 131072,
            "output": 98304
          }
        }
      }
    }
  }

Notice I've used "npm": "@ai-sdk/anthropic", but there is something wrong happens when running with this model:
Here is the full logs:

opencode run -m zai/glm-4.5 --print-logs "What is 1+1?"
INFO  2025-09-02T21:28:01 +83ms service=default version=0.6.3 args=["run","-m","zai/glm-4.5","--print-logs","What is 1+1?"] opencode
INFO  2025-09-02T21:28:01 +1ms service=project directory=/home/hakim fromDirectory
INFO  2025-09-02T21:28:01 +7ms service=config path=/home/hakim/.config/opencode/config.json loading
INFO  2025-09-02T21:28:01 +0ms service=config path=/home/hakim/.config/opencode/opencode.json loading
INFO  2025-09-02T21:28:01 +4ms service=config path=/home/hakim/.config/opencode/opencode.jsonc loading
INFO  2025-09-02T21:28:01 +9ms service=plugin path=file:///home/hakim/.config/opencode/plugin/notification.ts loading plugin
INFO  2025-09-02T21:28:01 +1ms service=plugin path=file:///home/hakim/.config/opencode/plugin/env.ts loading plugin
INFO  2025-09-02T21:28:01 +0ms service=plugin path=opencode-copilot-auth@0.0.2 loading plugin
INFO  2025-09-02T21:28:01 +1ms service=plugin path=opencode-anthropic-auth@0.0.2 loading plugin
INFO  2025-09-02T21:28:01 +13ms service=bus type=* subscribing
INFO  2025-09-02T21:28:01 +0ms service=bus type=session.updated subscribing
INFO  2025-09-02T21:28:01 +0ms service=bus type=message.updated subscribing
INFO  2025-09-02T21:28:01 +0ms service=bus type=message.part.updated subscribing
INFO  2025-09-02T21:28:01 +0ms service=format init
INFO  2025-09-02T21:28:01 +0ms service=bus type=file.edited subscribing
INFO  2025-09-02T21:28:01 +1ms service=session id=ses_6f3ab9b8bffeniuiq3H6lsv6w6 version=0.6.3 projectID=global directory=/home/hakim title=New session - 2025-09-02T21:28:01.396Z time={"created":1756848481396,"updated":1756848481396} created
INFO  2025-09-02T21:28:01 +0ms service=lsp serverIds=typescript, vue, eslint, gopls, ruby-lsp, pyright, elixir-ls, zls, csharp, rust, clangd enabled LSP servers
INFO  2025-09-02T21:28:01 +3ms service=bus type=session.updated publishing
INFO  2025-09-02T21:28:01 +1ms service=bus type=message.part.updated subscribing
INFO  2025-09-02T21:28:01 +0ms service=bus type=session.error subscribing
INFO  2025-09-02T21:28:01 +2ms service=session session=ses_6f3ab9b8bffeniuiq3H6lsv6w6 chatting
ERROR 2025-09-02T21:28:01 +0ms service=default e=undefined is not an object (evaluating 'app.path') rejection
INFO  2025-09-02T21:28:01 +1ms service=bus type=message.updated publishing
ERROR 2025-09-02T21:28:01 +0ms service=default e=undefined is not an object (evaluating 'app.path') rejection
INFO  2025-09-02T21:28:01 +0ms service=bus type=message.part.updated publishing
ERROR 2025-09-02T21:28:01 +1ms service=default e=undefined is not an object (evaluating 'app.path') rejection
INFO  2025-09-02T21:28:01 +0ms service=bus type=session.updated publishing
INFO  2025-09-02T21:28:01 +2ms service=models.dev file={} refreshing
ERROR 2025-09-02T21:28:01 +0ms service=default e=undefined is not an object (evaluating 'app.path') rejection
INFO  2025-09-02T21:28:01 +2ms service=provider init
INFO  2025-09-02T21:28:01 +1ms service=provider providerID=openrouter found
INFO  2025-09-02T21:28:01 +0ms service=provider providerID=zai found
INFO  2025-09-02T21:28:01 +0ms service=provider providerID=opencode found
INFO  2025-09-02T21:28:01 +0ms service=provider providerID=github-copilot found
INFO  2025-09-02T21:28:01 +0ms service=provider providerID=anthropic found
INFO  2025-09-02T21:28:01 +0ms service=provider providerID=bigboss found
INFO  2025-09-02T21:28:01 +0ms service=provider providerID=zai modelID=glm-4.5 getModel
INFO  2025-09-02T21:28:01 +0ms service=provider status=started providerID=zai getSDK
INFO  2025-09-02T21:28:01 +53ms service=provider status=completed duration=53 providerID=zai getSDK
INFO  2025-09-02T21:28:01 +0ms service=provider providerID=zai modelID=glm-4.5 found
INFO  2025-09-02T21:28:01 +1ms service=session session=ses_6f3ab9b8bffeniuiq3H6lsv6w6 sessionID=ses_6f3ab9b8bffeniuiq3H6lsv6w6 locking
INFO  2025-09-02T21:28:01 +9ms service=bus type=message.updated publishing
INFO  2025-09-02T21:28:01 +2ms service=mcp key=firecrawl-mcp type=local found
ERROR 2025-09-02T21:28:01 +2ms service=default e=undefined is not an object (evaluating 'app.path') rejection
INFO  2025-09-02T21:28:01 +483ms service=session session=ses_6f3ab9b8bffeniuiq3H6lsv6w6 type=start part
ERROR 2025-09-02T21:28:02 +236ms service=session session=ses_6f3ab9b8bffeniuiq3H6lsv6w6 error=Invalid JSON response Caused by: Type validation failed: Value: {"code":500,"msg":"404 NOT_FOUND","success":false}.
Error message: [{"code":"invalid_value","values":["message"],"path":["type"],"message":"Invalid input: expected \"message\""},{"expected":"array","code":"invalid_type","path":["content"],"message":"Invalid input: expected array, received undefined"},{"expected":"object","code":"invalid_type","path":["usage"],"message":"Invalid input: expected object, received undefined"}] model=glm-4.5 failed to generate title
INFO  2025-09-02T21:28:03 +847ms service=session session=ses_6f3ab9b8bffeniuiq3H6lsv6w6 type=finish-step part
INFO  2025-09-02T21:28:03 +3ms service=bus type=message.part.updated publishing
INFO  2025-09-02T21:28:03 +0ms service=bus type=message.updated publishing
INFO  2025-09-02T21:28:03 +1ms service=session session=ses_6f3ab9b8bffeniuiq3H6lsv6w6 type=finish part
INFO  2025-09-02T21:28:03 +0ms service=bus type=message.updated publishing
ERROR 2025-09-02T21:28:03 +0ms service=default e=undefined is not an object (evaluating 'app.path') rejection
ERROR 2025-09-02T21:28:03 +0ms service=default e=undefined is not an object (evaluating 'app.path') rejection
ERROR 2025-09-02T21:28:03 +0ms service=default e=undefined is not an object (evaluating 'app.path') rejection
INFO  2025-09-02T21:28:03 +1ms service=bus type=message.updated publishing
INFO  2025-09-02T21:28:03 +0ms service=session session=ses_6f3ab9b8bffeniuiq3H6lsv6w6 sessionID=ses_6f3ab9b8bffeniuiq3H6lsv6w6 unlocking

ERROR 2025-09-02T21:28:03 +2ms service=default e=undefined is not an object (evaluating 'app.path') rejection
INFO  2025-09-02T21:28:03 +0ms service=bus type=session.idle publishing
ERROR 2025-09-02T21:28:03 +1ms service=default e=undefined is not an object (evaluating 'app.path') rejection

So please let me know what I'm missing here, Thanks!

Activity

  1. github-actions commented on Sep 2, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The JSON validation errors you're experiencing appear to be the same underlying issue as #1298 and #1880, where the response format from GLM models doesn't match OpenCode's expected schema.

    Feel free to ignore if none of these address your specific case.

  2. Reidond commented on Sep 3, 2025

    @Reidond

    can you try setting baseURL to https://api.z.ai/api/anthropic/v1?

  3. shekohex commented on Sep 3, 2025

    @shekohex
    ContributorAuthor

    can you try setting baseURL to https://api.z.ai/api/anthropic/v1?

    This actually worked!! thanks! @Reidond

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions