feat: added support for z.ai coding plan via API as an alternative to anthropic#89
Open
mohitsinghdz wants to merge 1 commit intoKeygraphHQ:mainfrom
Open
feat: added support for z.ai coding plan via API as an alternative to anthropic#89mohitsinghdz wants to merge 1 commit intoKeygraphHQ:mainfrom
mohitsinghdz wants to merge 1 commit intoKeygraphHQ:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added support for Z.AI's GLM coding plan as an alternative LLM provider, allowing Shannon to run penetration tests using Z.AI's Anthropic-compatible API endpoint instead of direct Anthropic API or the router-based multi-model setup.
Changes
1. New
GLM=trueCLI flag (shannon)GLM=trueoption to theshannonCLI scripthttps://api.z.ai/api/anthropic)ANTHROPIC_AUTH_TOKENfromZAI_API_KEYfor authenticationROUTER=true(GLM takes priority with a warning)ZAI_API_KEYis set whenGLM=trueANTHROPIC_API_KEY="glm-mode"to satisfy SDK initialization2. Router config update (
configs/router-config.json)zaiprovider configuration pointing tohttps://api.z.ai/api/paas/v4/chat/completionsmax_completion_tokens: 16384transformer$ZAI_API_KEYenvironment variable for authentication3. Docker environment passthrough (
docker-compose.yml)ZAI_API_KEYto bothshannon-workerandclaude-code-routerservices4. GLM detection utility (
src/ai/router-utils.ts)isGlmDirectMode()function to detect when Z.AI direct mode is active (checks ifANTHROPIC_BASE_URLcontainsapi.z.ai)isRouterMode()to exclude GLM direct mode, preventing it from being incorrectly treated as router mode5. Environment example (
.env.example)OPTION 3: Z.AI GLM Modesection withZAI_API_KEYplaceholderGLM=trueflag usageUsage
Files Changed
shannonsrc/ai/router-utils.tsconfigs/router-config.jsondocker-compose.yml.env.exampleTest Plan
./shannon start URL=<url> REPO=<path> GLM=truewith a validZAI_API_KEYGLM=trueis set withoutZAI_API_KEYGLM=truetakes priority overROUTER=truewith a warningisGlmDirectMode()returns true when Z.AI endpoint is configuredisRouterMode()returns false in GLM direct mode