ChatGPTNextWeb / ChatGPT-Next-Web

A cross-platform ChatGPT/Gemini UI (Web / PWA / Linux / Win / MacOS). 一键拥有你自己的跨平台 ChatGPT/Gemini 应用。
https://app.nextchat.dev/
MIT License
72.56k stars 57.62k forks source link

[Bug] Not support key from https://github.com/chatanywhere/GPT_API_free #4828

Closed liudonghua123 closed 3 weeks ago

liudonghua123 commented 3 weeks ago

Bug Description

I got a free key and tested with openai python package with custom base_url="https://api.chatanywhere.tech/v1" successfully. But when I configured the same key in OpenAI API Key and "https://api.chatanywhere.tech/", "https://api.chatanywhere.tech" or "https://api.chatanywhere.tech/v1" in OpenAI Endpoint. None of them works.

The UI only shown this error.

{
  "error": true,
  "message": "empty response from server"
}

Steps to Reproduce

  1. open the windows desktop app
  2. fill key in OpenAI API Key, https://api.chatanywhere.tech in OpenAI Endpoint
  3. back to conversation and try to input something

Expected Behavior

work as expected.

Screenshots

image

Deployment Method

Desktop OS

Microsoft Windows [Version 10.0.22631.3672]

Desktop Browser

Edge

Desktop Browser Version

125

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

The tested code.

from openai import OpenAI

client = OpenAI(
    # defaults to os.environ.get("OPENAI_API_KEY")
    api_key="<the-key-from-GPT_API_free>",
    base_url="https://api.chatanywhere.tech/v1"
    # base_url="https://api.chatanywhere.cn/v1"
)

completion = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {
            "role": "user",
            "content": "How do I output all files in a directory using Python?",
        },
    ],
)
print(completion.choices[0].message.content)

image

liudonghua123 commented 3 weeks ago

I tested the same key and https://api.chatanywhere.tech as API Host in Chatbox, it's working as expected.

image

fred-bf commented 3 weeks ago

plz double check with you model provider

liudonghua123 commented 3 weeks ago

plz double check with you model provider

I use openai model provider and gpt4o model (also tried gpt3.5 model, but it's the same).

image

liudonghua123 commented 3 weeks ago

It's my mistake, I forgot to copy the complete key which contains sk- prefix. Now it's working.

image