st1vms / unofficial-claude-api

Unofficial Claude API supporting direct HTTP chat creation/deletion/retrieval, messages with multiple file attachments and auto session gathering using Firefox with geckodriver.
MIT License
131 stars 12 forks source link

Request failed with status code: 403 #5

Closed KrisshRp closed 11 months ago

KrisshRp commented 1 year ago

raise RuntimeError(f"Cannot retrieve Organization ID!\n{response.text}") RuntimeError: Cannot retrieve Organization ID! {"error": {"type": "permission_error", "message": "We are unable to serve your request"}}

st1vms commented 1 year ago

Please have a look at the TROUBLESHOOTING section, the reason you get this error is because of IP location restriction, try using a VPN connected to US/UK. Other locations may work sporadically or not work at all.

Closing this.

XiaoXinYo commented 1 year ago

same,But my web works fine using VPN,And other methods of unofficial-claude2-api can also be used, except for send_ Message

laserman2000 commented 1 year ago

I have tested with a server located in the US and it's not working...I get the same error

st1vms commented 12 months ago

Have you tried updating your session cookie from time to time? Also are you using the automatic session gathering with selenium, or the manual alternative?

XiaoXinYo commented 12 months ago

manual

------------------ Original ------------------ From: Stefano Raneri @.> Date: Tue,Nov 14,2023 8:02 PM To: st1vms/unofficial-claude2-api @.> Cc: Yang KaiQi @.>, Comment @.> Subject: Re: [st1vms/unofficial-claude2-api] Request failed with status code:403 (Issue #5)

Have you tried updating your session cookie from time to time? Also are you using the automatic session gathering with selenium, or the manual alternative?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

st1vms commented 12 months ago

manual ------------------ Original ------------------ From: Stefano Raneri @.> Date: Tue,Nov 14,2023 8:02 PM To: st1vms/unofficial-claude2-api @.> Cc: Yang KaiQi @.>, Comment @.> Subject: Re: [st1vms/unofficial-claude2-api] Request failed with status code:403 (Issue #5) Have you tried updating your session cookie from time to time? Also are you using the automatic session gathering with selenium, or the manual alternative? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Did you verified if cookie expired? You could give a shot to selenium auto session retrieval, also trying to run the example snippet to see if it works out...

st1vms commented 11 months ago

@KrisshRp @XiaoXinYo @laserman2000

Version 0.2.2 was released today, the 403 error seems to be fixed, also the library was updated to reflect new Claude 2.1 model!

Please let me know if this solves your issues...

XiaoXinYo commented 11 months ago

now i get curl_cffi.requests.errors.RequestsError: Failed to perform, ErrCode: 77, Reason: 'error setting certificate verify locations: CAfile: C:\Users\xxy\Documents\123\venv\Lib\site-packages\curl_cffi\cacert.pem CApath: none'. This may be a libcurl error, See https://curl.se/libcurl/c/libcurl-errors.html first for more details.

st1vms commented 11 months ago

@XiaoXinYo It may be a conflicting version of curl_cffi.

Have you tried clean reinstalling the libraries? ( in both virtual env and system packages ). So like issue this command in and outside the virtual env...

python -m pip uninstall unofficial-claude2-api curl_cffi

Then when you want to reinstall them, first upgrade curl_cffi:

python -m pip install --upgrade curl_cffi

Then reinstall this library:

python -m pip install unofficial-claude2-api

Also try a reboot after doing that...

If this doesn't work for you, would you please share your system informations? Such as OS, browsers installed, python version...

XiaoXinYo commented 11 months ago

@st1vms I have reinstalled all the packages, but still reported an error, regardless of whether I am using VPN or not

XiaoXinYo commented 11 months ago

@st1vms I manually get the cookies and ua Python3.11 Windows11 Edge 120.0.2210.61

st1vms commented 11 months ago

Looking at the libcurl error code reference page, this error seems to be:

CURLE_SSL_CACERT_BADFILE (77)

Problem with reading the SSL CA cert (path? access rights?) 

Have you tried installing and running outside virtual environment?

Cause the error states that the cafile.pem is not accessible, may be a problem on how curl_cffi interacts with virtual environments, or even a lack of permissions.

Also don't know if it may help, but try installing Firefox and reboot...

XiaoXinYo commented 11 months ago

@st1vms I don't think this is a problem caused by permissions (I have used administrator permissions) In addition, there is an error in the import of example. It should be from claude2_api.xxx IMG_6659

st1vms commented 11 months ago

Ok, thanks for spotting those typoos...

Have you tried the resolution steps I suggested before?

XiaoXinYo commented 11 months ago

I'm ready to rest. I'll get back to you tomorrow.

XiaoXinYo commented 11 months ago

I tried the method you gave me, but it still didn't work

st1vms commented 11 months ago

C:\Users\xxy\Documents\123\venv\Lib\site-packages\curl_cffi\cacert.pem

This file should be included in the curl_cffi library folder in your virtual environment site-packages, please could you walk along the path directories taken from that path the error returned, trying to find cacert.pem?

XiaoXinYo commented 11 months ago

Can be found

微信图片_20231210230413
st1vms commented 11 months ago

@XiaoXinYo Can you please try these steps to update libcurl on Windows?

Please post the output of

curl --version

I would also suggest to delete and reinstall python3.11, when installing also do not check any box rather than "Add to PATH".

When installing python packages please do not use a virtual environment and also retain from using the Admin shell.

Let me know for any further updates on this issue...

Thanks for your patience

XiaoXinYo commented 11 months ago

Thank you, it was unexpectedly resolved