ChatGPTAPIFree icon indicating copy to clipboard operation
ChatGPTAPIFree copied to clipboard

Error 429 : Too many requests

Open LincolnKermit opened this issue 2 years ago • 20 comments
trafficstars

Hello, I send a request with python, but I got this error.

requests.exceptions.JSONDecodeError: [Errno Expecting value]

429429 Too Many Requests: 0

Bests Regards

LincolnKermit avatar Mar 15 '23 19:03 LincolnKermit

This error message suggests that you have sent too many requests to the server and have exceeded the rate limit. The server has responded with a 429 status code, indicating that you should slow down your requests.

To solve this issue, you can try reducing the frequency of your requests or adding a delay between each request. You can also check if the server has an API documentation or a rate limit policy, which can provide guidance on the number of requests you can send in a given time period.

Another option is to handle the 429 response code in your Python code and retry the request after a certain amount of time has passed. You can use the built-in Python time.sleep() function to pause your code for a specified number of seconds before retrying the request.

ghost avatar Mar 15 '23 20:03 ghost

`import requests,json,time

headers = {"Content-Type": "application/json; charset=utf-8"} url = "https://chatgpt-api.shn.hk/v1/"

data = { "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Hello, how are you?"}], } time.sleep(5) response = requests.post(url, json=data) time.sleep(5) print("Status Code", response.status_code) time.sleep(5) print("JSON Response ", response.json())`

Even with some time.sleep i got the same error.

LincolnKermit avatar Mar 15 '23 21:03 LincolnKermit

I encounter the same issue when trying to curl from python or from Java, i can only curl from a batch script.

and it is only one single post request so i'm certain the issue is not that i actually send more requests than permitted

Moth-6 avatar Mar 15 '23 22:03 Moth-6

I also encountered the same issue, where I did not encounter any errors while making a curl request, but when using code written in Golang, I faced problems. Even sending a single request was causing the same issue

Rehtt avatar Mar 16 '23 02:03 Rehtt

https://github.com/ayaka14732/ChatGPTAPIFree/issues/24#issuecomment-1468323491

Probably a soft-request to not script it.

George-Seven avatar Mar 16 '23 06:03 George-Seven

`import requests,json,time

headers = {"Content-Type": "application/json; charset=utf-8"} url = "https://chatgpt-api.shn.hk/v1/"

data = { "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Hello, how are you?"}], } time.sleep(5) response = requests.post(url, json=data) time.sleep(5) print("Status Code", response.status_code) time.sleep(5) print("JSON Response ", response.json())`

Even with some time.sleep i got the same error.

You only made one request, which means the server replied with 429, but you just waited 5 seconds before printing it.

ErrorNoInternet avatar Mar 16 '23 08:03 ErrorNoInternet

this code solves problem in python:

session = requests.Session()
payload = {"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "hello!"}]}

r = requests.post("https://chatgpt-api.shn.hk/v1/", headers = {'Content-Type': 'application/json'}, data= json.dumps(payload))
answer = json.loads(r.text, strict=False)["choices"][0]["message"]["content"]

dm-vev avatar Mar 16 '23 14:03 dm-vev

Same problem here

OpenAI API responded: {
    "error": {
        "message": "You exceeded your current quota, please check your plan and billing details.",
        "type": "insufficient_quota",
        "param": null,
        "code": null
    }
}

0xWeverton avatar Mar 17 '23 20:03 0xWeverton

this code solves problem in python:

session = requests.Session()
payload = {"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "hello!"}]}

r = requests.post("https://chatgpt-api.shn.hk/v1/", headers = {'Content-Type': 'application/json'}, data= json.dumps(payload))
answer = json.loads(r.text, strict=False)["choices"][0]["message"]["content"]

It seems that it get a corrupted JSON... How to solve? Thank you:

Traceback (most recent call last): File "app.py", line 7, in answer = json.loads(r.text, strict=False) File "/usr/lib/python3.8/json/init.py", line 370, in loads return cls(**kw).decode(s) File "/usr/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

0ut0flin3 avatar Mar 20 '23 02:03 0ut0flin3

I'm getting this on my first request

acheong08 avatar Mar 20 '23 02:03 acheong08

I'm getting this on my first request

me too

0ut0flin3 avatar Mar 20 '23 02:03 0ut0flin3

Solved:

 $ curl https://chatgpt-api.shn.hk/v1/ \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "gpt-3.5-turbo",
  "messages": [{"role": "user", "content": "Hello, how are you?"}]
}' --user-agent "undici"

acheong08 avatar Mar 20 '23 02:03 acheong08

  • https://github.com/ayaka14732/ChatGPTAPIFree/issues/38
{
    "error": {
        "message": "Your access was terminated due to violation of our policies, please check your email for more information. If you believe this is in error and would like to appeal, please contact [email protected].",
        "type": "access_terminated",
        "param": null,
        "code": null
    }
}

acheong08 avatar Mar 20 '23 02:03 acheong08

没钱了 no money yet

dogeow avatar Mar 24 '23 10:03 dogeow

https://github.com/0ut0flin3/GPT1984

0ut0flin3 avatar Mar 24 '23 10:03 0ut0flin3

0ut0flin3/GPT1984

Pretty much the same as https://github.com/acheong08/ShareGPT but not open source? I think a slight issue is a lack of contribution.

acheong08 avatar Mar 24 '23 10:03 acheong08

0ut0flin3/GPT1984

Pretty much the same as https://github.com/acheong08/ShareGPT but not open source? I think a slight issue is a lack of contribution.

contributions are welcome, just wait for code to be uploaded

0ut0flin3 avatar Mar 24 '23 11:03 0ut0flin3

没钱了 no money yet

I think it is working for now

ayaka14732 avatar Mar 24 '23 15:03 ayaka14732

没钱了 no money yet

I think it is working for now

{'error': 'No API keys found'}

0ut0flin3 avatar Mar 25 '23 10:03 0ut0flin3

All API keys ran out of money.

acheong08 avatar Mar 25 '23 10:03 acheong08