{"id":1731,"date":"2023-11-15T17:59:47","date_gmt":"2023-11-15T08:59:47","guid":{"rendered":"https:\/\/tech.at-iroha.jp\/?p=1731"},"modified":"2026-04-06T13:51:25","modified_gmt":"2026-04-06T04:51:25","slug":"openai-vision-api-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e7%94%bb%e5%83%8f%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/tech.at-iroha.jp\/?p=1731","title":{"rendered":"OpenAI Vision API\u00a0\u3092\u4f7f\u3063\u305f\u753b\u50cf\u5206\u6790"},"content":{"rendered":"\n<p>2023\u5e7411\u6708\u306b\u958b\u50ac\u3055\u308c\u305f Open AI \u306e DevDay Conference \u3067\u306f\u591a\u304f\u306eAI\u95a2\u9023\u306e\u6a5f\u80fd\u3001\u30b5\u30fc\u30d3\u30b9\u304c\u767a\u8868\u3055\u308c\u307e\u3057\u305f\u3002\u305d\u306e\u4e2d\u3067\u3001GPT-4 Turbo with vision \u306b\u3064\u3044\u3066\u3082\u767a\u8868\u304c\u3042\u308a\u3001\u5b9f\u969b\u306bAPI\u304c\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>GPT-4 Turbo with vision  \u306f\u3001Open AI \u3078\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u9001\u4fe1\u3059\u308b\u969b\u3001\u5f93\u6765\u306e\u30c6\u30ad\u30b9\u30c8\u306b\u52a0\u3048\u3001\u753b\u50cf\u304c\u9001\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u9001\u4fe1\u5074\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u914d\u5217\u3092JSON\u5f62\u5f0f\u306b\u5909\u63db\u3057\u3001PHP\u5074\u3067JSON\u3092\u30c7\u30b3\u30fc\u30c9\u3057\u3001API \u306b\u9001\u4fe1\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">API\u306b\u9001\u4fe1\u3059\u308bJSON\u306e\u4e2d\u8eab<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ messages \u306e\u4e2d\u8eab\n&#91;\n    {\n\t'role' =&gt;  'user',\n\t'content' =&gt; &#91;\n\t\t&#91;'type' =&gt; 'text', 'text' =&gt;  '\u3053\u306e\u753b\u50cf\u3092\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3044\u3002'],\n\t\t&#91;\n\t\t\t'type' =&gt; 'image_url',\n\t\t\t'image_url' =&gt; 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/4\/44\/Cuisine_Trois_%C3%A9toiles.jpg',\n\t\t],\n\t]\n    },\n]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528\u3059\u308b\u753b\u50cf<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2023\/11\/image.png\" alt=\"\" class=\"wp-image-1735\" srcset=\"https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2023\/11\/image.png 1024w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2023\/11\/image-700x525.png 700w, https:\/\/tech.at-iroha.jp\/wp-content\/uploads\/2023\/11\/image-768x576.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n&lt;?php\n\/\/\n\/\/ OpenAI \u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210 ( https:\/\/beta.openai.com\/signup )\n\/\/ API Key \u3092\u53d6\u5f97 ( https:\/\/beta.openai.com\/account\/api-keys )\n\/\/\n$API_KEY = 'API Key';\n\n$header = &#91;\n\t'Authorization: Bearer '.$API_KEY,\n\t'Content-type: application\/json',\n];\n\n$messages = json_decode($_POST&#91;'messages'], true);\n\n$params = json_encode(&#91;\n\t'model'\t\t\t=&gt; 'gpt-4-vision-preview',\n\t'messages'\t\t=&gt; $messages,\n]);\n\n$curl = curl_init('https:\/\/api.openai.com\/v1\/chat\/completions');\n\n$options = &#91;\n\tCURLOPT_POST =&gt; true,\n\tCURLOPT_HTTPHEADER =&gt;$header,\n\tCURLOPT_POSTFIELDS =&gt; $params,\n\tCURLOPT_RETURNTRANSFER =&gt; true,\n];\n\ncurl_setopt_array($curl, $options);\n$response = curl_exec($curl);\n$httpcode = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);\n\nif(200 == $httpcode)\n{\n\t$json_array = json_decode($response, true);\n\t$choices = $json_array&#91;'choices'];\n\t\n\tforeach($choices as $c)\n\t{\n\t\techo $c&#91;'message']&#91;'content'].'&lt;br&gt;';\n\t}\n}\n?&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u51fa\u529b\u7d50\u679c<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-style-plain has-background is-layout-flow wp-block-quote-is-layout-flow\" style=\"background-color:#fafafa\">\n<p>\u3053\u306e\u753b\u50cf\u306f\u3001\u30d5\u30a9\u30fc\u30de\u30eb\u306a\u30bb\u30c3\u30c6\u30a3\u30f3\u30b0\u306e\u98df\u5353\u3092\u6620\u3057\u3066\u3044\u307e\u3059\u3002\u4e2d\u592e\u306b\u306f\u3001\u30af\u30ea\u30fc\u30df\u30fc\u306a\u30b9\u30fc\u30d7\u304c\u5165\u3063\u305f\u6df1\u76bf\u304c\u7f6e\u304b\u308c\u3066\u304a\u308a\u3001\u305d\u306e\u4e0a\u306b\u306f\u30af\u30eb\u30c8\u30f3\u3068\u898b\u3089\u308c\u308b\u30c8\u30fc\u30b9\u30c8\u3055\u308c\u305f\u30d1\u30f3\u304c\u4e57\u305b\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u30b9\u30fc\u30d7\u306f\u304a\u305d\u3089\u304f\u4f55\u304b\u306e\u30cf\u30fc\u30d6\u304c\u52a0\u3048\u3089\u308c\u3066\u304a\u308a\u3001\u7dd1\u8272\u3067\u3042\u308b\u3053\u3068\u304b\u3089\u3001\u305d\u306e\u3088\u3046\u306b\u898b\u53d7\u3051\u3089\u308c\u307e\u3059\u3002 \u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001\u4e21\u30b5\u30a4\u30c9\u306b\u9280\u8272\u306e\u30ca\u30a4\u30d5\u3068\u30b9\u30d7\u30fc\u30f3\u304c\u3001\u307e\u305f\u30b9\u30fc\u30d7\u306e\u76bf\u306e\u524d\u306b\u306f\u30d5\u30a9\u30fc\u30af\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u5404\u30ab\u30c8\u30e9\u30ea\u30fc\u306f\u5149\u6ca2\u304c\u3042\u308a\u3001\u6e05\u6f54\u306b\u6574\u3048\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u98df\u5668\u306f\u6a21\u69d8\u304c\u63cf\u304b\u308c\u305f\u88c5\u98fe\u7684\u306a\u7e01\u53d6\u308a\u304c\u7279\u5fb4\u7684\u3067\u3001\u8d64\u3068\u91d1\u8272\u306e\u914d\u8272\u304c\u30d5\u30a9\u30fc\u30de\u30eb\u306a\u96f0\u56f2\u6c17\u3092\u91b8\u3057\u51fa\u3057\u3066\u3044\u307e\u3059\u3002 \u80cc\u666f\u306b\u307c\u3093\u3084\u308a\u898b\u3048\u308b\u4ed6\u306e\u76bf\u306b\u306f\u3001\u30b9\u30fc\u30d7\u76bf\u3068\u306f\u7570\u306a\u308b\u6599\u7406\u304c\u76db\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u8a73\u7d30\u306f\u306f\u3063\u304d\u308a\u3057\u307e\u305b\u3093\u3002\u5de6\u5074\u306e\u5c0f\u76bf\u306b\u306f\u30d0\u30bf\u30fc\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u4e57\u305b\u3089\u308c\u3066\u304a\u308a\u3001\u30c6\u30fc\u30d6\u30eb\u306e\u4e0a\u306b\u306f\u30b0\u30e9\u30b9\u985e\u3082\u8907\u6570\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30c6\u30fc\u30d6\u30eb\u306e\u4e0a\u306e\u7d19\u306b\u306f\u4f55\u304b\u6587\u5b57\u304c\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u3082\u5185\u5bb9\u306f\u5224\u5225\u3067\u304d\u307e\u305b\u3093\u3002 \u5168\u4f53\u3092\u901a\u3057\u3066\u3001\u3053\u306e\u98df\u4e8b\u74b0\u5883\u306f\u9ad8\u7d1a\u30ec\u30b9\u30c8\u30e9\u30f3\u3084\u7279\u5225\u306a\u30a4\u30d9\u30f3\u30c8\u3067\u306e\u30c7\u30a3\u30ca\u30fc\u30b7\u30fc\u30f3\u3092\u9023\u60f3\u3055\u305b\u3001\u7dfb\u5bc6\u306b\u914d\u3055\u308c\u305f\u30c6\u30fc\u30d6\u30eb\u30a6\u30a7\u30a2\u304c\u30a8\u30ec\u30ac\u30f3\u30c8\u306a\u98df\u4e8b\u4f53\u9a13\u3092\u4e88\u611f\u3055\u305b\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>2023\u5e7411\u6708\u306b\u958b\u50ac\u3055\u308c\u305f Open AI \u306e DevDay Conference \u3067\u306f\u591a\u304f\u306eAI\u95a2\u9023\u306e\u6a5f\u80fd\u3001\u30b5\u30fc\u30d3\u30b9\u304c\u767a\u8868\u3055\u308c\u307e\u3057\u305f\u3002\u305d\u306e\u4e2d\u3067\u3001GPT-4 Turbo with vision \u306b\u3064\u3044\u3066\u3082\u767a\u8868\u304c\u3042\u308a\u3001\u5b9f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1735,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-1731","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nlp"],"_links":{"self":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts\/1731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1731"}],"version-history":[{"count":6,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts\/1731\/revisions"}],"predecessor-version":[{"id":1739,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/posts\/1731\/revisions\/1739"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=\/wp\/v2\/media\/1735"}],"wp:attachment":[{"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.at-iroha.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}