feat: add OpenAI client wrapper
This commit is contained in:
@@ -1 +1,18 @@
|
||||
// OpenAI API client wrapper.
|
||||
|
||||
import OpenAI from "openai";
|
||||
|
||||
/**
|
||||
* Create an OpenAI SDK client from the loaded config.
|
||||
* @param {object} config - Config object from loadConfig()
|
||||
* @param {string} config.openaiApiKey - Required. The OpenAI API key.
|
||||
* @returns {OpenAI} The configured OpenAI SDK client instance.
|
||||
*/
|
||||
export function createOpenAIClient(config) {
|
||||
if (!config?.openaiApiKey) {
|
||||
throw new Error("Missing config.openaiApiKey.");
|
||||
}
|
||||
return new OpenAI({
|
||||
apiKey: config.openaiApiKey,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user