Skip to content

Commit 1a4ac7c

Browse files
committed
fix: make API key optional in constructor
- Removed error throw when API key is missing in IOIntelligenceHandler constructor
1 parent d9ba9a9 commit 1a4ac7c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/api/providers/__tests__/io-intelligence.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,16 @@ describe("IOIntelligenceHandler", () => {
168168
expect(handler["options"]).toEqual(mockOptions)
169169
})
170170

171-
it("should throw error when API key is missing", () => {
171+
it("should allow handler creation without API key for model fetching", () => {
172172
const optionsWithoutKey = { ...mockOptions }
173173
delete optionsWithoutKey.ioIntelligenceApiKey
174174

175-
expect(() => new IOIntelligenceHandler(optionsWithoutKey)).toThrow("IO Intelligence API key is required")
175+
// Handler can be created without API key (validation happens at UI level)
176+
const handlerWithoutKey = new IOIntelligenceHandler(optionsWithoutKey)
177+
expect(handlerWithoutKey).toBeInstanceOf(IOIntelligenceHandler)
178+
expect(handlerWithoutKey["client"]).toBeDefined()
179+
// Client should have a placeholder API key
180+
expect(handlerWithoutKey["client"].apiKey).toBe("not-provided")
176181
})
177182

178183
it("should handle streaming response correctly", async () => {

src/api/providers/io-intelligence.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ export class IOIntelligenceHandler extends BaseProvider implements SingleComplet
2222
super()
2323
this.options = options
2424

25-
if (!options.ioIntelligenceApiKey) {
26-
throw new Error("IO Intelligence API key is required")
27-
}
28-
25+
// API key is optional for model discovery, but required for actual API calls
2926
this.client = new OpenAI({
3027
baseURL: "https://api.intelligence.io.solutions/api/v1",
31-
apiKey: options.ioIntelligenceApiKey,
28+
apiKey: options.ioIntelligenceApiKey || "not-provided",
3229
defaultHeaders: DEFAULT_HEADERS,
3330
})
3431
}

0 commit comments

Comments
 (0)