Fix Z.AI credential resolution and improve 401 auth diagnostics
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user