LoginSignup
12
12

More than 1 year has passed since last update.

速報:ChatGPTのAPIを叩いてみた

Last updated at Posted at 2022-12-01

ChatGPT凄いですね。話題ですね!
早速やってみました。
https://openai.com/blog/chatgpt/

スクリーンショット 2022-12-01 20.38.15.png
下にスクロールし TRY CHATGPTをクリック
スクリーンショット 2022-12-01 20.38.41.png
スクリーンショット 2022-12-01 20.38.49.png
SingUp
スクリーンショット 2022-12-01 20.38.58.png
スクリーンショット 2022-12-01 20.39.06.png
スクリーンショット 2022-12-01 20.42.04.png
スクリーンショット 2022-12-01 20.42.10.png
電話番号入れる
スクリーンショット 2022-12-01 20.42.22.png
スクリーンショット 2022-12-01 20.42.49.png
I'm building a product or feature を選択

チュートリアルに進みます。
https://beta.openai.com/docs/quickstart

k.morikawa@gMacBook-Pro-2 openAIchat % git clone https://github.com/openai/openai-quickstart-node.git  
Cloning into 'openai-quickstart-node'...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 30 (delta 8), reused 5 (delta 5), pack-reused 14
Receiving objects: 100% (30/30), 66.24 KiB | 3.31 MiB/s, done.
Resolving deltas: 100% (8/8), done.

スクリーンショット 2022-12-01 21.19.02.png
Create new secret key をクリックし、APIキーを生成します

cd openai-quickstart-node
cp .env.example .env
vi .env

.envに下記を設定します。
OPENAI_API_KEY=さっき取得したAPIキー設定

k.morikawa@MacBook-Pro-2 openai-quickstart-node % npm install             


up to date, audited 25 packages in 643ms

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
k.morikawa@MacBook-Pro-2 openai-quickstart-node % npm run dev

> openai-quickstart-node@0.1.0 dev
> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/k.morikawa/Desktop/openAIchat/openai-quickstart-node/.env
wait  - compiling...
event - compiled client and server successfully in 1029 ms (113 modules)
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
wait  - compiling / (client and server)...
wait  - compiling...
event - compiled client and server successfully in 1068 ms (132 modules)

起動したので、http://localhost:3000にアクセスします。
スクリーンショット 2022-12-01 21.26.04.png

dogと入れて動かしてみたら下の方表示された。

スクリーンショット 2022-12-01 21.27.51.png

とりあえず動きました。
この後、Understand the codeに進んで、ソースコード読んでみます。

続きはこちらです。
続:ChatGPTのAPI調査
続:ChatGPTのAPI調査・その2

ChatGPTの中身についてはこちらにまとめました。
必見:ChatGPTのテクノロジーの凄さについて

12
12
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12