Fix Z.AI credential resolution and improve 401 auth diagnostics

This commit is contained in:
William Valentin
2026-02-15 19:47:27 -08:00
parent 81c97a9df1
commit dd15ccb927
5 changed files with 83 additions and 23 deletions
+20
View File
@@ -185,6 +185,26 @@ describe('createClientFromConfig', () => {
}
});
it('creates OpenAIClient for zhipuai using ZAI_API_KEY env var without use_oauth', async () => {
const prev = process.env.ZAI_API_KEY;
process.env.ZAI_API_KEY = 'zai-api-key';
try {
const { createClientFromConfig } = await loadFactory();
const client = createClientFromConfig({
provider: 'zhipuai',
model: 'glm-4.7',
});
expect(client.constructor.name).toBe('OpenAIClient');
} finally {
if (prev === undefined) {
delete process.env.ZAI_API_KEY;
} else {
process.env.ZAI_API_KEY = prev;
}
}
});
it('creates OpenAIClient for minimax provider', async () => {
const prev = process.env.MINIMAX_API_KEY;
process.env.MINIMAX_API_KEY = 'test-key';