LoginSignup
54
15

More than 1 year has passed since last update.

OpenAI APIのエラー(openai.error.RateLimitError)について

Posted at

エラー発生状況

OpenAI APIのアカウントを作成してAPIキーを発行し、PythonでChatGPT APIを使おうとしたときに以下のエラーが発生しました。

Ubuntu
  File "/usr/local/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 226, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 619, in _interpret_response
    self._interpret_response_line(
  File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 679, in _interpret_response_line
    raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

料金プランなど設定した覚えがないので最初見たときは正直ビビりました。

原因

クレジットカード支払いの設定を行った上で上限金額の設定を行う必要があったらしいです。

クレジットカード支払いの設定手順

まず、以下の料金設定ページから「Set up paid account」をクリックします。

Qiita3.png

個人開発であれば上の「I'm an individual」、企業で使うのであれば下の「I'm working on behalf of a company」をクリックし、
クレジットカード情報や住所などを入力して登録します。

Qiita4.png

上限金額の設定手順

左タブの「Billing」下にある「Usage limits」をクリックし、赤丸で囲った部分に上限金額を入力します。
(デフォルトの$120は少し怖かったので自分は下げています)
入力したらその下の「Save」ボタンをクリックします。

Qiita6.png

これでAPIを叩いてみると先ほどのエラーは消えているかと思います。

54
15
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
54
15