https://platform.openai.com/docs/api-reference
const axios = require("axios");
const apiKey = "발급받은 KEY"; // Replace with your OpenAI API key
const apiUrl = "https://api.openai.com/v1/chat/completions"; //
const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
};
const data = {
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: "" }],
};
axios
.post(apiUrl, data, { headers })
.then((response) => {
console.log(response.data); // Process the API response as desired
})
.catch((error) => {
console.error("Error:", error);
});
const axios = require("axios");
const apiKey = "발급받은 KEY"; // Replace with your OpenAI API key
const apiUrl = "https://api.openai.com/v1/images/generations"; //
const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
};
const data = {
prompt: "make application image which was descriptioin of travel",
n: 2,
size: "1024x1024",
};
axios
.post(apiUrl, data, { headers })
.then((response) => {
console.log(response.data); // Process the API response as desired
})
.catch((error) => {
console.error("Error:", error);
});