OpenAI API

Hvvany·2023년 5월 18일
0

OpenAI

목록 보기
1/1

공식문서

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);
  });
profile
Just Do It

0개의 댓글