Featured image of post WindowsのコマンドプロンプトでChatGPT APIをcurlから呼び出す方法

WindowsのコマンドプロンプトでChatGPT APIをcurlから呼び出す方法

Windowsのコマンドプロンプト(cmd)を使って、curlコマンドからOpenAIのChatGPT APIを呼び出す方法を解説します。必要なコマンドやパラメーターの設定方法をわかりやすく紹介します。

ChatGPT APIをcurlから呼び出す

Windowsのコマンドプロンプトから呼び出すことを前提としています。

1
2

curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer sk-proj-XXXXXXXXXXXXXXXXXXXX" -d "{""model"": ""gpt-3.5-turbo"",""messages"": [{""role"": ""system"", ""content"": ""関西弁で答えてください。""}, {""role"": ""user"", ""content"": ""ここに送りたいメッセージを挿入する""}]}"
comments powered by Disqus