0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Curl: ChatGPT API の使い方

Last updated at Posted at 2023-04-02

参考ページ

Create chat completion

スクリプト

go_fujisan.sh
API_KEY="sk-****************'
curl https://api.openai.com/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer '$API_KEY \
  -d '{
  "model": "gpt-3.5-turbo",
  "messages": [{"role": "user", "content": "富士山の高さは"}]
}' > out01.json
#
jq .choices[0].message out01.json

実行結果

$ ./go_fujisan.sh 
{
  "role": "assistant",
  "content": "3776メートルです。"
}

関連情報

Httpie: ChatGPT API の使い方
Node.js: ChatGPT API の使い方 (https)
Node.js: ChatGPT API の使い方 (axios)
Node.js: ChatGPT API の使い方 (node-fetch)
Deno: ChatGPT API の使い方
Julia: ChatGPT API の使い方

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?