Models: add Vercel AI Gateway auth
This commit is contained in:
committed by
Peter Steinberger
parent
0dcffcd5b0
commit
beb9eac5f7
@@ -256,4 +256,28 @@ describe("getApiKeyForModel", () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves Vercel AI Gateway API key from env", async () => {
|
||||
const previousGatewayKey = process.env.AI_GATEWAY_API_KEY;
|
||||
|
||||
try {
|
||||
process.env.AI_GATEWAY_API_KEY = "gateway-test-key";
|
||||
|
||||
vi.resetModules();
|
||||
const { resolveApiKeyForProvider } = await import("./model-auth.js");
|
||||
|
||||
const resolved = await resolveApiKeyForProvider({
|
||||
provider: "vercel-ai-gateway",
|
||||
store: { version: 1, profiles: {} },
|
||||
});
|
||||
expect(resolved.apiKey).toBe("gateway-test-key");
|
||||
expect(resolved.source).toContain("AI_GATEWAY_API_KEY");
|
||||
} finally {
|
||||
if (previousGatewayKey === undefined) {
|
||||
delete process.env.AI_GATEWAY_API_KEY;
|
||||
} else {
|
||||
process.env.AI_GATEWAY_API_KEY = previousGatewayKey;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user