Add Anthropic Messages API support for Zhipu GLM coding plan#235
Add Anthropic Messages API support for Zhipu GLM coding plan#235adisusilayasa wants to merge 1 commit intosipeed:mainfrom
Conversation
|
We make a provider related refactor in #283 , could you please change the code into new provider way. Another, Z.AI can use zhipu provider in model_list, using OpenAI-style, is Anthropic-style really needed? |
Refactor to use protocol-based model_list configuration instead of adding Anthropic-style API support. Zhipu GLM coding plan can use the existing zhipu/ protocol with a custom api_base. Changes: - Add glm-4.7 model config to config.example.json - Document Zhipu GLM coding plan endpoint configuration in README - Add Chinese documentation for Zhipu GLM coding plan in README.zh.md The new architecture (PR sipeed#492) supports zero-code provider addition through protocol-based model_list configuration. Addressing reviewer feedback: - Use new protocol-based provider way from PR sipeed#492 - Zhipu GLM coding plan can use OpenAI-style (zhipu/) protocol - No code changes needed, just configuration
499dd18 to
085f030
Compare
|
Thank you for the feedback! After deep research into Zhipu GLM coding plan official documentation (docs.z.ai), I've confirmed that:
ConclusionZhipu GLM coding plan works perfectly with the existing What Was ChangedI've refactored this PR to use the new protocol-based provider architecture from PR #492: Documentation Changes Only (No Code Modifications)
How Users Configure Zhipu GLM Coding PlanWith the new architecture, users can simply configure it in {
"model_list": [
{
"model_name": "glm-4.7-coding",
"model": "zhipu/glm-4.7",
"api_key": "your-zhipu-key",
"api_base": "https://api.z.ai/api/coding/paas/v4"
}
],
"agents": {
"defaults": {
"model": "glm-4.7-coding"
}
}
}This uses the existing, proven Addresses Reviewer Concerns✅ "Could you please change the code into new provider way?"
✅ "Z.AI can use zhipu provider in model_list, using OpenAI-style, is Anthropic-style really needed?"
The PR now contains only documentation updates showing how to use Zhipu GLM coding plan with the new protocol-based architecture. This is a simpler, more maintainable approach that avoids the compatibility issues encountered with the Anthropic-style implementation. |
Summary
This PR adds support for the Anthropic Messages API format, enabling PicoClaw to work with Zhipu's GLM coding plan and other Anthropic-compatible APIs.
Changes
apiBasepath containing/anthropicChat()into two methods:chatOpenAI()- handles OpenAI-style chat completionschatAnthropic()- handles Anthropic Messages API formattool_useandtextcontent blocksx-api-key,anthropic-version)/v1/messagesand/messagesendpointsparseAnthropicResponse()for parsing Anthropic-style responsesWhy This Matters
This enables users to use:
https://api.z.ai/api/anthropic/v1)glm-4.7(and other GLM models)Testing
Tested successfully with:
Example test:
Configuration Example
{ "agents": { "defaults": { "provider": "zhipu", "model": "glm-4.7" } }, "providers": { "zhipu": { "api_key": "your-api-key", "api_base": "https://api.z.ai/api/anthropic/v1" } } }🤖 Generated with Claude Code