on main help sign in
fix: handle z.ai key validation differently
58eda7ckujtimiihoxha
internal/config/config.go+10−3
@@ -508,7 +508,7 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
508 if baseURL == "" {
508 if baseURL == "" {
509 baseURL = "https://api.openai.com/v1"
509 baseURL = "https://api.openai.com/v1"
510 }
510 }
511− if c.ID == "openrouter" {
511+ if c.ID == string(catwalk.InferenceProviderOpenRouter) {
512 testURL = baseURL + "/credits"
512 testURL = baseURL + "/credits"
513 } else {
513 } else {
514 testURL = baseURL + "/models"
514 testURL = baseURL + "/models"
@@ -546,8 +546,15 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
546 if err != nil {
546 if err != nil {
547 return fmt.Errorf("failed to create request for provider %s: %w", c.ID, err)
547 return fmt.Errorf("failed to create request for provider %s: %w", c.ID, err)
548 }
548 }
549+ if c.ID == string(catwalk.InferenceProviderZAI) {
550+ if b.StatusCode == http.StatusUnauthorized {
551+ // for z.ai just check if the http response is not 401
552+ return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
553+ }
554+ } else {
549− if b.StatusCode != http.StatusOK {
555+ if b.StatusCode != http.StatusOK {
550− return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
556+ return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
557+ }
551 }
558 }
552 _ = b.Body.Close()
559 _ = b.Body.Close()
553 return nil
560 return nil