@@ -508,7 +508,7 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
508508 if baseURL == "" {
509509 baseURL = "https://api.openai.com/v1"
510510 }
511− if c.ID == "openrouter" {
511+ if c.ID == string(catwalk.InferenceProviderOpenRouter) {
512512 testURL = baseURL + "/credits"
513513 } else {
514514 testURL = baseURL + "/models"
@@ -546,8 +546,15 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
546546 if err != nil {
547547 return fmt.Errorf("failed to create request for provider %s: %w", c.ID, err)
548548 }
549− if b.StatusCode != http.StatusOK {
550− return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
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 {
555+ if b.StatusCode != http.StatusOK {
556+ return fmt.Errorf("failed to connect to provider %s: %s", c.ID, b.Status)
557+ }
551558 }
552559 _ = b.Body.Close()
553560 return nil