chatanywhere / GPT_API_free

Free ChatGPT API Key,免费ChatGPT API,支持GPT4 API(免费),ChatGPT国内可用免费转发API,直连无需代理。可以搭配ChatBox等软件/插件使用,极大降低接口使用成本。国内即可无限制畅快聊天。
MIT License
19.08k stars 1.46k forks source link

免费API报错403 #246

Open zyk516 opened 1 month ago

zyk516 commented 1 month ago

代码如下: from openai import OpenAI import os

client = OpenAI(

This is the default and can be omitted

api_key=os.environ["OPENAI_API_KEY"],
base_url="https://api.chatanywhere.tech/v1"

) COMPLETION_MODEL = "gpt-3.5-turbo"

prompt = """ Consideration product : 工厂现货PVC充气青蛙夜市地摊热卖充气玩具发光蛙儿童水上玩具

  1. Compose human readable product title used on Amazon in english within 20 words.
  2. Write 5 selling points for the products in Amazon.
  3. Evaluate a price range for this product in U.S.

Output the result in json format with three properties called title, selling_points and price_range """

def get_response(prompt): completions = client.completions.create( model=COMPLETION_MODEL, prompt=prompt, max_tokens=512, n=1, stop=None, temperature=0.0, ) message = completions.choices[0].text return message

print(get_response(prompt)) 报错信息: PermissionDeniedError: Error code: 403 - {'error': {'message': '免费API限制使用gpt-3.5-turbo,gpt-4 和 embeddings模型,如有更多需求,请访问 https://buyca.shop 购买付费API。The free account is limited to use gpt-3.5-turbo, gpt-4 and embeddings. If you have additional requirements, please visit https://buyca.shop/ to purchase a premium key.', 'type': 'chatanywhere_error', 'param': None, 'code': '403 FORBIDDEN'}}

免费API限制使用gpt-3.5-turbo,但我使用的就是gpt-3.5-turbo模型啊,为什么还会报错呢? 求解答,多谢

ynpl commented 1 month ago

说明你代码哪里还是有问题

ynpl commented 1 month ago

你可以试试chatbox是不是报错

chatanywhere commented 1 month ago

大概率是因为调用的Completion接口而不是ChatCompletion接口,没有提供完整的代码这边无法准确定位问题

duxingxingstar commented 1 month ago

我也遇到此错误 代码如下 from dotenv import load_dotenv # 用于加载环境变量 load_dotenv() # 加载 .env 文件中的环境变量 from langchain_openai import OpenAI llm = OpenAI(model_name="gpt-3.5-turbo" , max_tokens=200) text = llm.invoke("请给我写一句情人节红玫瑰的中文宣传语") print(text)

Tuscan-blue commented 1 week ago

Now

我的解决方案:创建一个新会话

Before

我也遇到类似的错误 image