{"id":3689,"date":"2023-08-04T19:40:53","date_gmt":"2023-08-04T10:40:53","guid":{"rendered":"https:\/\/blog.since2020.jp\/?p=3689"},"modified":"2023-08-04T19:44:51","modified_gmt":"2023-08-04T10:44:51","slug":"chatgpt-api%e3%81%ab%e3%82%88%e3%82%8b%e7%94%bb%e5%83%8f%e7%94%9f%e6%88%90%e3%81%a8%e3%82%ad%e3%83%a3%e3%83%97%e3%82%b7%e3%83%a7%e3%83%b3%e5%9f%8b%e3%82%81%e8%be%bc%e3%81%bf%e3%80%8c%e3%83%93%e3%82%b8","status":"publish","type":"post","link":"https:\/\/since2020.jp\/media\/chatgpt-api%e3%81%ab%e3%82%88%e3%82%8b%e7%94%bb%e5%83%8f%e7%94%9f%e6%88%90%e3%81%a8%e3%82%ad%e3%83%a3%e3%83%97%e3%82%b7%e3%83%a7%e3%83%b3%e5%9f%8b%e3%82%81%e8%be%bc%e3%81%bf%e3%80%8c%e3%83%93%e3%82%b8\/","title":{"rendered":"ChatGPT API\u306b\u3088\u308b\u753b\u50cf\u751f\u6210\u3068\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u57cb\u3081\u8fbc\u307f\u300c\u30d3\u30b8\u30e5\u30a2\u30eb\u30b3\u30f3\u30c6\u30f3\u30c4\u4f5c\u6210\u3078\u306e\u4e00\u6b69\u300d"},"content":{"rendered":"\n<p>\u4eca\u56de\u306fChatGPT\u306eAPI\u3092\u4f7f\u7528\u3057\u3066\u3001\u81ea\u7136\u8a00\u8a9e\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u753b\u50cf\u3092\u751f\u6210\u3057\u3001\u305d\u306e\u753b\u50cf\u306b\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u57cb\u3081\u8fbc\u3080\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n<span style=\"font-family: arial, helvetica, sans-serif\">\u4eca\u56de\u306fChatGPT(OpenAI)\u306eAPI\u3092\u4f7f\u7528\u3057\u3066\u3001\u81ea\u7136\u8a00\u8a9e\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u753b\u50cf\u3092\u751f\u6210\u3057\u3001\u305d\u306e\u753b\u50cf\u306b\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u57cb\u3081\u8fbc\u3080\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u3001\u30c7\u30fc\u30bf\u5206\u6790\u3068AI\u306e\u4f1a\u793e\u306e\u30aa\u30d5\u30a3\u30b9\u306e\u753b\u50cf\u3092\u751f\u6210\u3057\u3001\u753b\u50cf\u5185\u306b\u300cSiNCE\u682a\u5f0f\u4f1a\u793e \u7a4d\u6975\u63a1\u7528\u4e2d\u300d\u3068\u3044\u3046\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/span>\n\n<h2>\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/h2>\n<span style=\"font-family: arial, helvetica, sans-serif\">\u6700\u521d\u306b\u3001\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/span>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import openai\r\nimport matplotlib.pyplot as plt\r\nimport requests\r\nfrom PIL import Image\r\nfrom io import BytesIO\r\nimport matplotlib.font_manager as fm<\/code><\/pre>\r\n<\/div>\n\n<h2>\u65e5\u672c\u8a9e\u30d5\u30a9\u30f3\u30c8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u8a2d\u5b9a<\/h2>\n<span style=\"font-family: arial, helvetica, sans-serif\">\u6b21\u306b\u3001\u65e5\u672c\u8a9e\u30d5\u30a9\u30f3\u30c8\uff08Takao\u30d5\u30a9\u30f3\u30c8\uff09\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/span>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>!apt-get -y install fonts-takao\r\nfont_path = '\/usr\/share\/fonts\/truetype\/takao-gothic\/TakaoGothic.ttf'\r\nfont_prop = fm.FontProperties(fname=font_path)<\/code><\/pre>\r\n<\/div>\n\n<h2>\u753b\u50cf\u751f\u6210\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u8a2d\u5b9a<\/h2>\n<span style=\"font-family: arial, helvetica, sans-serif\">\u63cf\u753b\u3057\u305f\u3044\u30b7\u30fc\u30f3\u3092\u6587\u7ae0\u3067\u8a18\u8ff0\u3057\u3001\u30d7\u30ed\u30f3\u30d7\u30c8\u3068\u3057\u3066\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u30d7\u30ed\u30f3\u30d7\u30c8\u306f\u65e5\u672c\u8a9e\u3067\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u82f1\u8a9e\u306e\u65b9\u304c\u3088\u308a\u7cbe\u5ea6\u306e\u9ad8\u3044\u753b\u50cf\u3092\u751f\u6210\u3067\u304d\u308b\u305f\u3081\u4eca\u56de\u306f\u82f1\u8a9e\u3067\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/span>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>prompt = \"data analysis and AI company's modern office, filled with cutting-edge technology.\"<\/code><\/pre>\r\n<\/div>\n\n<h2>GPT\u3067\u306e\u753b\u50cf\u751f\u6210<\/h2>\n<span style=\"font-family: arial, helvetica, sans-serif\">OpenAI\u306e\u753b\u50cf\u751f\u6210\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3057\u3066\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u753b\u50cf\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/span>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>openai.api_key =\"your-api-key\"\r\n\r\nresponse = openai.Image.create(prompt=prompt, n=1, size=\"512x512\", response_format=\"url\")\r\nimage_url = response['data'][0]['url']\r\nimage_response = requests.get(image_url)\r\nimage = Image.open(BytesIO(image_response.content))<\/code><code><\/code><\/pre>\r\n<\/div>\n\n<h2>\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u306e\u57cb\u3081\u8fbc\u307f<\/h2>\n<span style=\"font-family: arial, helvetica, sans-serif\">matplotlib\u3092\u4f7f\u7528\u3057\u3066\u3001\u751f\u6210\u3055\u308c\u305f\u753b\u50cf\u5185\u306b\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u57cb\u3081\u8fbc\u307f\u307e\u3059\u3002<\/span>\r\n<div class=\"hcb_wrap\">\r\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>fig, ax = plt.subplots()\r\nax.imshow(image)\r\nax.axis('off') \r\nplt.text(30, 460, \"SiNCE\u682a\u5f0f\u4f1a\u793e \u7a4d\u6975\u63a1\u7528\u4e2d\", fontsize=12, color='white', backgroundcolor='purple', fontproperties=font_prop\uff09\r\n\r\nplt.show()<\/code><\/pre>\r\n<\/div>\n\n<h2>\u307e\u3068\u3081<\/h2>\n<span style=\"font-family: arial, helvetica, sans-serif\">GPT\u3067\u306e\u753b\u50cf\u751f\u6210\u3068\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u57cb\u3081\u8fbc\u307f\u306f\u3001\u30d3\u30b8\u30e5\u30a2\u30eb\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3068\u81ea\u52d5\u5316\u306b\u65b0\u3057\u3044\u53ef\u80fd\u6027\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u3001\u5e83\u544a\u3001\u30a8\u30f3\u30bf\u30fc\u30c6\u30a4\u30e1\u30f3\u30c8\u306a\u3069\u3001\u591a\u5c90\u306b\u308f\u305f\u308b\u5206\u91ce\u3067\u306e\u5fdc\u7528\u304c\u671f\u5f85\u3055\u308c\u307e\u3059\u3002<\/span>","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fChatGPT\u306eAPI\u3092\u4f7f\u7528\u3057\u3066\u3001\u81ea\u7136\u8a00\u8a9e\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u753b\u50cf\u3092\u751f\u6210\u3057\u3001\u305d\u306e\u753b\u50cf\u306b\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u57cb\u3081\u8fbc\u3080\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u306f\u3058\u3081\u306b \u4eca\u56de\u306fChatGPT(OpenAI)\u306eAPI\u3092\u4f7f\u7528\u3057\u3066\u3001\u81ea\u7136\u8a00\u8a9e\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089 [&hellip;]<\/p>\n","protected":false},"author":87,"featured_media":3155,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","swell_btn_cv_data":"","footnotes":"","_wp_rev_ctl_limit":""},"categories":[1249],"tags":[96,478,145,376,380],"class_list":{"0":"post-3689","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-knowledge","8":"tag-ai","10":"tag-api","11":"tag-chatgpt","12":"tag-openai"},"_links":{"self":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/3689","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/comments?post=3689"}],"version-history":[{"count":1,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/3689\/revisions"}],"predecessor-version":[{"id":3693,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/posts\/3689\/revisions\/3693"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media\/3155"}],"wp:attachment":[{"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/media?parent=3689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/categories?post=3689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/since2020.jp\/media\/wp-json\/wp\/v2\/tags?post=3689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}