在将我的API密钥放入基本代码时,gpt 3.5 Turbo出现问题

mbjcgjjk  于 2023-10-24  发布在  其他
关注(0)|答案(1)|浏览(294)
import openai
import os
import sys
  
try:
  openai.api_key = os.environ['OPENAI_API_KEY']
except KeyError:
  sys.stderr.write("""
  You haven't set up your API key yet.
  
  If you don't have an API key yet, visit:
  
  https://platform.openai.com/signup

  1. Make an account or sign in
  2. Click "View API Keys" from the top right menu.
  3. Click "Create new secret key"

  Then, open the Secrets Tool and add OPENAI_API_KEY as a secret.
  """)
  exit(1)

response = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]
)

print(response)

我得到了这个错误:

 python3 main.py
Traceback (most recent call last):
  File "/home/runner/AI-Code-1/main.py", line 23, in \<module\>
    response = openai.ChatCompletion.create(
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(\*args, \*\*kwargs)
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, \_, api_key = requestor.request(
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 226, in request
    resp, got_stream = self.\_interpret_response(result, stream)
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 619, in \_interpret_response
    self.\_interpret_response_line(
  File "/home/runner/AI-Code-1/venv/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.
exit status 1
hfsqlsce

hfsqlsce1#

根据您的日志:

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details

相关问题