Handle Z.AI textual 401 errors for auth diagnostics

This commit is contained in:
William Valentin
2026-02-15 19:50:15 -08:00
parent dd15ccb927
commit d44bfc300b
3 changed files with 20 additions and 3 deletions
+2 -1
View File
@@ -260,9 +260,10 @@ export class OpenAIClient implements ModelClient {
const message = error instanceof Error ? error.message : String(error);
const isZai = (this.baseURL ?? '').includes('api.z.ai');
const isUnauthorized401 = status === 401 || /\b401\b/.test(message);
const missingModelRequestScope = message.includes('Missing scopes: model.request');
if (isZai && status === 401) {
if (isZai && isUnauthorized401) {
const hint = missingModelRequestScope
? 'The key lacks `model.request` scope.'
: 'The API key is invalid, expired, or not allowed for this model/endpoint.';