Skip to content

feat: proper Z.AI implementation — dual OpenAI+Anthropic endpoints, plan separation (general + Coding Plan), regions (global/cn) - #49

Merged
Patel230 merged 4 commits into
mainfrom
feat/z-ai-dual-endpoints-plans-regions
Jun 15, 2026
Merged

feat: proper Z.AI implementation — dual OpenAI+Anthropic endpoints, plan separation (general + Coding Plan), regions (global/cn)#49
Patel230 merged 4 commits into
mainfrom
feat/z-ai-dual-endpoints-plans-regions

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Summary

Full proper implementation for Z.AI following the plan in docs/plans/z-ai-proper-implementation.md and the Xiaomi precedent exactly.

  • Plan separation: z-ai (general pay-as-you-go) + z-ai-coding (GLM Coding Plan subscription). Distinct CredentialEnv (ZAI_API_KEY vs ZAI_CODING_API_KEY), LiveFetcherKey, DeploymentID, base defaults.
  • Both endpoints: New dual-protocol client/zai.go (OpenAI-compat paas/coding primary + Anthropic-compat /api/anthropic fallback on retriable errors, using ProtocolRouter). Same key works for both protocols.
  • Regions: catalog/zai/ with Plan/Region types + resolvers for global (api.z.ai) and cn (open.bigmodel.cn family) affecting both OpenAI and Anthropic bases. Hawk region picker (global/cn) for Z.AI rows, persisted in provider.json, env injection via ApplyZAIRegionEnv.
  • Live discovery: Plan-specific /models (coding path gets the subscription-appropriate list).
  • UX: New chat_config_zai.go + zai_setup.go (picker, g hotkey, hints, pre-key region flow, display labels). Fully wired into gateways/keys/panel/deployment flows.
  • Config/eyrie: ProviderConfig + profiles extended, deployment uses NewZAIClient for both ZAI gateways, fetchers updated.
  • Docs: Detailed new subsection in CREDENTIAL-SETUP-FLOW.md with tables (dual endpoints + plans + regions) + updates elsewhere. 19 gateways.
  • Tests: New table-driven in catalog/zai, updated gateway count (19) + alias tests, -race clean on changed packages.

Backward compat: Existing z-ai + keys + BASE_URL overrides continue to work (now also get the Anthropic fallback benefit). New coding gateway is additive.

Verification

  • go test -race -count=1 green for config, gateways, zai package, client, setup.
  • Both endpoints active in the dual client for plan-specific gateways.
  • Feature branch + conventional commits (no co-authors).
  • Pushed and PR created via gh.

Refs the official Z.AI docs (explicit coding/paas/v4 for Coding Plan + /anthropic compat for Claude Code etc.).

This makes Z.AI first-class and as robust/dynamic/reused as the rest of the 19 gateways.

(eyrie side committed in parallel in external/eyrie on its feature branch; root records the submodule advance.)

Patel230 added 4 commits June 15, 2026 14:55
…OpenAI+Anthropic)

- New internal/config/zai_setup.go and cmd/chat_config_zai.go (region picker global/cn, Needs/Set/Apply, modeled 1:1 on xiaomi)
- Wire region flow, 'g' hotkey hints, Apply env, display labels, key paste pre-steps into chat_config_* (gateways, keys, panel, deployment)
- catalog_api.go alias support for z-ai-coding
- catalog_gateways_test.go: 19 gateways (z-ai + z-ai-coding)
- chat_model.go: configZAIRegionSel field
- Include the full implementation plan doc (docs/plans/z-ai-proper-implementation.md)
- Pairs with eyrie commit (catalog/zai/, client/zai.go dual, registry two specs, deployment NewZAIClient for both, fetchers, config fields)

Both endpoints (OpenAI primary + Anthropic fallback) + proper plan separation now fully wired in TUI and execution.

Per AGENTS.md: feature branch, tests alongside, -race green on relevant pkgs.

(Depends on eyrie submodule update from parallel commit in external/eyrie)
@Patel230
Patel230 merged commit d9883a2 into main Jun 15, 2026
18 checks passed
@Patel230
Patel230 deleted the feat/z-ai-dual-endpoints-plans-regions branch June 15, 2026 21:50
Patel230 added a commit that referenced this pull request Jun 18, 2026
…lan separation (general + Coding Plan), regions (global/cn) (#49)

* feat: hawk Z.AI gateway UI + config bridge for dual plans + regions (OpenAI+Anthropic)

- New internal/config/zai_setup.go and cmd/chat_config_zai.go (region picker global/cn, Needs/Set/Apply, modeled 1:1 on xiaomi)
- Wire region flow, 'g' hotkey hints, Apply env, display labels, key paste pre-steps into chat_config_* (gateways, keys, panel, deployment)
- catalog_api.go alias support for z-ai-coding
- catalog_gateways_test.go: 19 gateways (z-ai + z-ai-coding)
- chat_model.go: configZAIRegionSel field
- Include the full implementation plan doc (docs/plans/z-ai-proper-implementation.md)
- Pairs with eyrie commit (catalog/zai/, client/zai.go dual, registry two specs, deployment NewZAIClient for both, fetchers, config fields)

Both endpoints (OpenAI primary + Anthropic fallback) + proper plan separation now fully wired in TUI and execution.

Per AGENTS.md: feature branch, tests alongside, -race green on relevant pkgs.

(Depends on eyrie submodule update from parallel commit in external/eyrie)

* feat: hawk Z.AI gateway UI + config bridge for dual plans + regions (OpenAI+Anthropic)

* chore(submodules): align eyrie to f3abc3b (Z.AI plan separation)

* docs(plans): replace hard tabs with spaces in z-ai-proper-implementation.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant