Skip to content

[Bug]: Interactive provider onboarding presets the Z.AI/Zhipu general API-plan endpoint, so Coding Plan keys fail the connectivity test and nothing is saved #259

Description

@SvenMeyer

Environment

  • MiniMax Code (@minimax-ai/code) 0.5.0, npm install, Linux, Node v24.18.0
  • Region: outside China (international)
  • Z.AI Coding Plan API key

Summary

Adding Z.AI / GLM-5.3 through the interactive provider flow fails with a valid key, and no provider is written to config.yaml. The onboarding preselects the Z.AI general API plan endpoint (https://api.z.ai/api/paas/v4), but a Coding Plan key only works against the coding endpoint (https://api.z.ai/api/coding/paas/v4). The connectivity test fails, and because the flow tests before persisting, nothing is saved.

I had to hand-write the custom_provider block in config.yaml to get GLM-5.3 working.

Root cause

The provider-preset catalog pins a region-specific preferred provider list, but it uses the general API-plan provider ids rather than the coding-plan ones:

packages/local-runtime-v2/src/service/model-system/catalog/provider-presets/provider-presets.service.ts:21-28

const DISABLED_PROVIDER_IDS = new Set([
  'minimax',
  'minimax-cn',
  'minimax-coding-plan',
  'minimax-cn-coding-plan',
]);
const REGION_PINNED_PROVIDER_IDS = {
  cn: ['zhipuai', 'deepseek', 'moonshotai-cn', 'openai', 'anthropic'],
  en: ['zai', 'deepseek', 'moonshotai', 'openai', 'anthropic'],
} as const;

models.dev (the source of these presets) exposes four relevant providers, and mcode's cached snapshot contains all four:

provider id base URL plan region
zai https://api.z.ai/api/paas/v4 general API international
zai-coding-plan https://api.z.ai/api/coding/paas/v4 Coding Plan international
zhipuai https://open.bigmodel.cn/api/paas/v4 general API China
zhipuai-coding-plan https://open.bigmodel.cn/api/coding/paas/v4 Coding Plan China

REGION_PINNED_PROVIDER_IDS only pins zai (international) / zhipuai (China). Pinned ids are sorted to the front, so the top entry in the picker is "Z.AI" → the general endpoint. The coding-plan presets are present but buried below it, and the labels ("Z.AI" vs "Z.AI Coding Plan") do not make the endpoint difference obvious.

Region detection itself works (cn → bigmodel, en → api.z.ai); the problem is that it selects the general plan, not the coding plan.

Reproduction

  1. Outside China, with a Z.AI Coding Plan key, open /provider (or run mcode provider) and pick the top Z.AI preset.
  2. Enter the (valid) Coding Plan key and model glm-5.3.
  3. The connectivity test fails and no custom_provider entry is written to ~/.minimax/config.yaml.

Verified with curl using the same key:

  • POST https://api.z.ai/api/paas/v4/chat/completions (general) → 429
    {"error":{"code":"1113","message":"Insufficient balance or no resource package. Please recharge."}}
  • POST https://api.z.ai/api/coding/paas/v4/chat/completions (coding) → 200

So the test fails purely because it targets the wrong plan's endpoint, not because the key is wrong.

Expected behavior

  • Include the coding-plan presets in the region-pinned lists, e.g.:
    cn: ['zhipuai-coding-plan', 'zhipuai', ...],
    en: ['zai-coding-plan', 'zai', ...],
    and label them clearly ("Z.AI Coding Plan" vs "Z.AI API").
  • Better: auto-detect. When the connectivity test against the general endpoint returns 401/429/"insufficient balance" for a zai/zhipuai key, retry once against the matching coding endpoint and save that on success. Both endpoints use the same bearer-token shape, so this is cheap and removes the guesswork for the common case (coding plans are the plan most users buy).
  • UX: today the failure leaves no config entry and the reason is not stated. Either save the candidate first and mark it unverified, or say explicitly that nothing was saved and that the endpoint likely does not match the plan (see also mcode provider add --use fails with "Test the saved provider configuration" but saves nothing #157).

Notes

  • models.dev's env var for these providers is ZHIPU_API_KEY, not ZAI_API_KEY, which is another onboarding gotcha for Z.AI users.
  • Inconsistency worth reconciling: mcode's bundled model catalog maps the zai provider id to the coding URL (https://api.z.ai/api/coding/paas/v4) and zai-coding-cn to the bigmodel coding URL, while the BYOK provider-preset flow maps zai to the general URL. The same id means different endpoints depending on the surface.
  • GLM-5.3 is present in all four models.dev presets, so this is purely an endpoint/selection problem, not a missing-model problem.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliStandalone mcode: TUI, headless, ACP and source builds/toolingneeds-triageAwaiting maintainer assessment

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions