Files
gh-jezweb-claude-skills-ski…/templates/chat-completion-basic.ts
2025-11-30 08:25:12 +08:00

25 lines
526 B
TypeScript

// Basic Chat Completion with GPT-5
// Simple example showing the minimal setup for chat completions
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
async function basicChatCompletion() {
const completion = await openai.chat.completions.create({
model: 'gpt-5',
messages: [
{
role: 'user',
content: 'What are the three laws of robotics?'
}
],
});
console.log(completion.choices[0].message.content);
}
basicChatCompletion();