Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Error 429 : Too many requests #27

Open
LincolnKermit opened this issue Mar 15, 2023 · 20 comments
Open

Error 429 : Too many requests #27

LincolnKermit opened this issue Mar 15, 2023 · 20 comments

Comments

@LincolnKermit
Copy link

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

requests.exceptions.JSONDecodeError: [Errno Expecting value] <!doctype html><title>429</title>429 Too Many Requests: 0

Bests Regards

@ghost
Copy link

ghost commented Mar 15, 2023

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.

@LincolnKermit
Copy link
Author

`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.

@Moth-6
Copy link

Moth-6 commented Mar 15, 2023

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

@Rehtt
Copy link

Rehtt commented Mar 16, 2023

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

@George-Seven
Copy link

#24 (comment)

Probably a soft-request to not script it.

@ErrorNoInternet
Copy link

`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.

@dm-vev
Copy link

dm-vev commented Mar 16, 2023

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"]

@tom-log
Copy link

tom-log commented Mar 17, 2023

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
    }
}

@0ut0flin3
Copy link

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)

@acheong08
Copy link

I'm getting this on my first request

@0ut0flin3
Copy link

I'm getting this on my first request

me too

@acheong08
Copy link

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
Copy link

{
    "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
    }
}

@dogeow
Copy link

dogeow commented Mar 24, 2023

没钱了 no money yet

@0ut0flin3
Copy link

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

@acheong08
Copy link

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.

@0ut0flin3
Copy link

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

@ayaka14732
Copy link
Owner

没钱了 no money yet

I think it is working for now

@0ut0flin3
Copy link

没钱了 no money yet

I think it is working for now

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

@acheong08
Copy link

All API keys ran out of money.

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

No branches or pull requests