実現したいこと
以下を参考に、PowerApps(PowerAutomate)のカスタムコネクタを作成し、
ChatGPT APIと接続したいですが、下記のAPI認証エラーにより正常な結果が返ってきません。
認証エラーを解消する方法をご教授いただきたいです。
前提
以下、コマンドプロンプトに自身のChatGPT APIのキーを入力し、
実行すると、正常に接続できることは確認できるため、APIキーに問題はないこと確認しております。
※ChatGPTは無料版を利用しています。
cmd
1curl -X POST https://api.openai.com/v1/chat/completions ^ 2 -H "Content-Type: application/json" ^ 3 -H "Authorization: Bearer 【自身のAPIキー】" ^ 4 -d "{\"model\": \"gpt-3.5-turbo\",\"messages\": [{\"role\": \"user\", \"content\": \"how are you?\"}]}"
発生している問題・エラーメッセージ
Swaggerエディタでリクエストとレスポンスを確認すると以下の通りでした。
※【自身のAPIキー】には上記コマンドプロントで利用できたAPIキーと同一のもとが入力されています。
request
1curl -X 'POST' \ 2 'https://api.openai.com/v1/chat/completions' \ 3 -H 'accept: application/json' \ 4 -H 'Content-Type: application/json' \ 5 -H 'Authorization: 【自身のAPIキー】' \ 6 -d '{ 7 "model": "gpt-3.5-turbo", 8 "messages": [ 9 { 10 "role": "user", 11 "content": "hello" 12 } 13 ] 14}'
Request
1https://api.openai.com/v1/chat/completions
ServerResponse
1401 Error: Unauthorized 2 3{ 4 "error": { 5 "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.", 6 "type": "invalid_request_error", 7 "param": null, 8 "code": null 9 } 10}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/05/22 13:53