OpenAI Connector
Integrate OpenAI's GPT models into your Logic Bee hooks.
Setup
// logic-bee.config.ts
export default {
connectors: {
openai: {
apiKey: process.env.OPENAI_API_KEY,
model: 'gpt-4o',
},
},
};
Usage
@LogicHook({
event: 'generate-product-description',
collection: 'ai',
})
export class GenerateProductDescriptionHook {
async run(context) {
const { productName, features } = context.body;
const response = await context.connectors.openai.chat({
messages: [
{ role: 'system', content: 'You are a product copywriter.' },
{ role: 'user', content: `Write a description for ${productName} with features: ${features.join(', ')}` },
],
});
return { description: response.content };
}
}
Configuration Options
| Option | Type | Description |
|---|---|---|
apiKey | string | Your OpenAI API key |
model | string | Model to use (default: gpt-4o) |
temperature | number | Sampling temperature (0–2) |
maxTokens | number | Default max tokens for completions |
organization | string | Optional organization ID |