Skip to content

feat: add GLM (ZhipuAI) support to playground#5608

Open
colegottdank wants to merge 1 commit intomainfrom
feat/add-glm-playground-support
Open

feat: add GLM (ZhipuAI) support to playground#5608
colegottdank wants to merge 1 commit intomainfrom
feat/add-glm-playground-support

Conversation

@colegottdank
Copy link
Collaborator

No description provided.

- Add ZhipuAI provider for direct GLM API access
- Add glm-4.6:zai and glm-4.7:zai endpoints
- Add provider model ID to canonical model ID mapping
- Update playground to resolve provider-specific model IDs (e.g., "zai-glm-4.7") to canonical IDs (e.g., "glm-4.7")
- Update model registry to include providerModelIdMap in response

This allows users to open requests made with provider-specific model IDs (like Cerebras's "zai-glm-4.7") in the playground without falling back to gpt-4o-mini.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
helicone Error Error Feb 25, 2026 7:12pm
helicone-bifrost Ready Ready Preview, Comment Feb 25, 2026 7:12pm
helicone-eu Error Error Feb 25, 2026 7:12pm

Request Review

@supabase
Copy link

supabase bot commented Feb 25, 2026

This pull request has been ignored for the connected project bolqqmqbrciybnypvklh because there are no changes detected in supbase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@supabase
Copy link

supabase bot commented Feb 25, 2026

This pull request has been ignored for the connected project lmahfbbnchpworytrrqk because there are no changes detected in .supabase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@claude
Copy link
Contributor

claude bot commented Feb 25, 2026

Claude finished @colegottdank's task —— View job


PR Review: GLM (ZhipuAI) Playground Support

Review Checklist:

  • Read repository guidelines (CLAUDE.md)
  • Review cost calculation changes
  • Analyze model registry modifications
  • Check playground UI integration
  • Examine test snapshots
  • Assess security and performance
  • Check code quality and best practices
  • Provide final score and recommendations

Score: 7/10 - Good implementation with some improvements suggested

This PR adds GLM (ZhipuAI) support to the playground with comprehensive cost modeling and multiple provider endpoints. The implementation is solid but has several areas for improvement.

Critical Issues Found:

1. Context Length Inconsistency 🚨

Location: packages/cost/models/authors/zai/glm-4/endpoints.ts

There are inconsistent context lengths across providers for the same model:

  • glm-4.6:canopywave: 204,800 tokens
  • glm-4.6:baseten: 200,000 tokens
  • glm-4.7:canopywave: 198,000 tokens
  • glm-4.7:fireworks: 198,000 tokens
  • glm-4.7:cerebras: 131,072 tokens

Fix: Verify actual context lengths with provider documentation and standardize where the same model should have the same limits.

2. Missing Type Definition

Location: packages/cost/models/authors/zai/glm-4/endpoints.ts:3

import { ZaiModelName } from "./models";

This import suggests a ./models.ts file should exist but isn't included in the PR.

Fix: Either include the missing models.ts file or remove this import if not needed.

3. Duplicate Model IDs

Location: packages/cost/models/authors/zai/glm-4/endpoints.ts:317,344

Both glm-4.6:zai and glm-4.7:zai use the same providerModelId: "glm-4-plus". This could cause routing confusion.

Fix: Clarify if these should have different provider model IDs or if they truly map to the same underlying model.

Code Quality Issues:

4. Hardcoded Currency Conversion

Location: packages/cost/models/authors/zai/glm-4/endpoints.ts:323

input: 0.00000714, // 0.05 CNY/1K tokens ≈ $0.00714/1K

Issue: Exchange rates fluctuate, making hardcoded conversions unreliable.

Suggestion: Either:

  • Use a currency conversion service
  • Document the exchange rate and date used
  • Consider pricing in CNY with automatic conversion

5. Provider Slug Mapping Gap

Location: valhalla/jawn/src/controllers/public/modelRegistryController.ts:84-94

The getProviderSlug method doesn't include a mapping for "zai":

private getProviderSlug(provider: string): string {
  const slugMap: Record<string, string> = {
    // ... other providers
    // Missing: zai: "zhipuai" or similar
  };
  return slugMap[provider.toLowerCase()] || provider.toLowerCase();
}

Fix: Add explicit mapping for ZAI provider.

Performance & Best Practices:

6. Model Registry Caching

The frontend properly implements caching with staleTime: 1000 * 60 * 60 (1 hour), which is appropriate.

7. Efficient Model Filtering

The model selection logic in useModelRegistry.tsx efficiently filters and sorts models.

8. Type Safety

Good use of TypeScript with proper interfaces and type assertions where needed.

Security Assessment:

9. URL Validation

Base URLs and endpoints are properly validated and use HTTPS.

10. No Hardcoded Secrets

No API keys or sensitive information in the code.

Suggestions Summary:

High Priority:

  1. Fix context length inconsistencies - Could cause user confusion and incorrect billing
  2. Add missing ZaiModelName import/file - Breaks TypeScript compilation
  3. Resolve duplicate providerModelId issue - Could cause routing problems

Medium Priority:

  1. Document currency conversion methodology - Important for pricing transparency
  2. Add ZAI provider slug mapping - Improves UX consistency
  3. Add model configuration validation - Prevent similar issues in future

Low Priority:

  1. Consider adding GLM model descriptions - Would improve user experience
  2. Add integration tests for new endpoints - Ensure reliability

Breaking Changes Assessment:

No breaking changes detected - This is an additive feature that doesn't modify existing APIs.

Additional Notes:

  • The test snapshots correctly capture the new models
  • Playground integration follows existing patterns
  • Provider integration is comprehensive with good parameter support
  • Documentation links are helpful for users

Recommended Actions:

  1. Address the critical context length and duplicate ID issues
  2. Add/fix missing type imports
  3. Run npx tsc --noEmit in packages to verify type correctness
  4. Consider adding basic integration tests for the ZAI provider

The foundation is solid - these improvements will ensure reliability and consistency with the existing codebase.


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