Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api无效 Incorrect API key provided #305

Open
free0010 opened this issue Oct 11, 2024 · 1 comment
Open

api无效 Incorrect API key provided #305

free0010 opened this issue Oct 11, 2024 · 1 comment

Comments

@free0010
Copy link

import openai

替换为你的 OpenAI API 密钥

openai.api_key = "OPENAI_API_KEY"
openai.base_url="https://api.chatanywhere.org"

def chat_with_gpt(prompt):
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo', # 或者使用其他可用模型
messages=[
{"role": "user", "content": prompt}
]
)
return response['choices'][0]['message']['content']

if name == "main":
user_input = input("你想问什么? ")
reply = chat_with_gpt(user_input)
print("GPT的回复:", reply)

之前成功调用了一次今天在打开key就无效了,用的3.5的免费模型,端口也改了但是一直报错求解

@ynpl
Copy link

ynpl commented Oct 12, 2024

Python的示例: https://github.com/chatanywhere/GPT_API_free/blob/main/demo.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants