Files
genesis-2/supabase/functions/ai-structured/index.ts
T

23 lines
573 B
TypeScript

import OpenAI from 'jsr:@openai/openai';
Deno.serve(async (req) => {
const apiKey = Deno.env.get('OPENAI_API_KEY')
const openai = new OpenAI({
apiKey: apiKey,
})
// Documentation here: https://github.com/openai/openai-node
const response = await openai.responses.create({
model: 'gpt-5-nano',
instructions: 'You are a coding assistant that talks like a pirate',
input: 'Are semicolons optional in JavaScript?',
});
const reply = response.output_text
return new Response(reply, {
headers: { 'Content-Type': 'text/plain' },
})
})