import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.naga.ac/v1',
apiKey: 'YOUR_API_KEY',
});
const response = await client.responses.create({
model: 'gpt-4.1',
input: 'Extract the event details from: Alice and Bob are going to a science fair on Friday.',
text: {
format: {
type: 'json_schema',
name: 'calendar_event',
schema: {
type: 'object',
properties: {
name: { type: 'string' },
date: { type: 'string' },
participants: {
type: 'array',
items: { type: 'string' },
},
},
required: ['name', 'date', 'participants'],
additionalProperties: false,
},
strict: true,
},
},
});
console.log(response.output_text);