// ChatGPT 모델 설정 const MODEL_ID = "gpt-4o"; // 원하는 모델 ID로 변경 가능 function GPT(prompt) { const apiKey = PropertiesService.getScriptProperties().getProperty("OpenAI_API_Key"); if (!prompt) { return "Error: Please provide a valid prompt."; // 사용자 입력이 null인 경우 오류 메시지 출력 } const apiUrl = "https://api.openai.com/v1/chat/completions"; // 엔드포인트 수정 const data = { model: MODEL_ID, messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: prompt } ], max_tokens: 1000 }; const headers = { "Content-Type": "application/json", "Authorization": "Bearer " + apiKey }; const options = { "method" : "POST", "headers" : headers, "payload" : JSON.stringify(data) }; const response = UrlFetchApp.fetch(apiUrl, options); const result = JSON.parse(response.getContentText()); return result.choices[0].message.content; }