hataraku
Version:
An autonomous coding agent for building AI-powered development tools. The name "Hataraku" (働く) means "to work" in Japanese.
26 lines • 876 B
JavaScript
import { createOpenAI } from '@ai-sdk/openai';
/**
* Create an OpenAI provider with the given API key
* @param apiKey OpenAI API key (optional, defaults to OPENAI_API_KEY environment variable)
* @returns OpenAI provider
*/
export async function createOpenAIProvider(apiKey) {
const key = apiKey || process.env.OPENAI_API_KEY;
if (!key) {
throw new Error('OPENAI_API_KEY is not set');
}
return createOpenAI({
apiKey: key
});
}
/**
* Create an OpenAI model with the given model name
* @param model Model name (defaults to gpt-4o)
* @param apiKey OpenAI API key (optional, defaults to OPENAI_API_KEY environment variable)
* @returns OpenAI model
*/
export async function createOpenAIModel(model = 'gpt-4o', apiKey) {
const openai = await createOpenAIProvider(apiKey);
return openai(model);
}
//# sourceMappingURL=openai.js.map