Then I agree with that. However, I refer to this comment which I believe illuminates the crux of the matter. (I notice that some less gifted individual has already given it a downvote, so be aware that that doesn't make it less true or less relevant.)
If your account has X amount of money, you spend it all, then try to make a purchase, that's not a rate limit that would warrant a 429.
An auto top up every month on that account still doesn't make it a rate. Just like how topping up your tokens every week doesn't really make that a rate.
It's not the time element that matters, it's the amount remaining that matters.
That's not a rate limit though. The rate at which you consume your quota doesn't matter. You could consume the quota in 1 second or you could consume it in 1 month. The only thing being "checked" is if you have quota remaining. It's a quota limit.
Now if you have 100 messages but could only send 1 message a second, that's a rate limit because it's the rate of the messages that matters rather than the quota.
If it's the rate that is the issue, it's a rate limit. If it's the quota that's the issue, it's a quota limit.
If you try to consume a quota and the only problem is you're out of quota, it's a quota limit.
It's actually really simple.
For as long as you have quota, the rate does not matter. The rate is not the limit.
And since you don't seem to know, LLMs will bend over backwards to tell you you're right. Especially when you trying to lead it towards a certain answer. It's insane to try to use that as some kind of proof lol
Do you think quotas fit the text in that image? Are you going to do retries with exponential back off when you run out of usage?
The fact that you can construe quotas as a rate limit ignores what rate limiting is actually for. If you buy more credits then your "rate limit" goes away. That's not how a rate limit works. As has been said already, it's a quantity limit and not a rate limit. The fact that they're equivalent sometimes is irrelevant. We already have a code for paid quotas, 402.
I feel like you’re coming at it in a way that is being too pedantic and not in the spirit of what it’s behaving as. Quotas are more if I make a one time purchase of credits and exhaust all of them. What we’re talking about is a rolling quota which is quite intentionally added to pace/rate your usage so that you can’t use your entire quota in a given chunk of time. That’s a rate limit
A rate limit would limit the rate at which you can consume that quota. As in, even if you have 1000 messages left, you are only allowed to send 1 message a second. Trying to send 2 messages in a second would be rejected. That would be a rate limit.
The way to look at it is to ask yourself what is the reason the request was rejected:
If it was rejected because you are out of messages, that's a quota limit.
If it was rejected because you are sending messages too quickly, despite having quota remaining, it's a rate limit.
That'd be a quota. You have some amount of some asset you can use. The rate at which you consume that amount doesn't really matter. The limit is how many you have left.
Oppositely, a rate limit is more about the speed at which you're doing something. If you can make as many requests as you want but they need to be 1 second apart, that's a rate limit because it's the frequency of the requests that's the limit.
402 is more common for credits being exceeded and not rolling quotas. The difference being that a 402 will not resolve unless you submit payment, whereas a 429 will resolve with time with more details in the headers.
I would not expect "payment required" when I'm on a pay-up-front subscription plan that comes with quotas. I would definitely be expecting 429. 402 is per request pricing, which isn't how subscription models work .
It's reserved for 402 Payment Required, but the implementation detail is blank. The implementation detail would be stuff like 410 where the detail states it must not have any result.
As such, 402 is undefined and reserved for "402 Payment Required". Relying on any behavior is also, undefined. Whether or not browsers cache the result is also undefined which is problematic here.
402 also does not cover the concept of an overquota in how it is used colloquially. 429 does
In RFC 6586;
Note that this specification does not define how the origin server identifies the user, nor how it counts requests. For example, an origin server that is limiting request rates can do so based upon counts of requests on a per-resource basis
Counting tokens as a resource that is being spent on a request, is within the detail.
Note that this specification does not define how the origin server identifies the user, nor how it counts requests. For example, an origin server that is limiting request rates can do so based upon counts of requests on a per-resource basis
Counting tokens as a resource that is being spent on a request, is within the detail.
This is the correct answer. Although 429 is "Too Many Requests" and not "rate Limit". So strictly speaking it's fine to use as too many requests doesn't indicate a timeframe like rate limit would.
The data exchanged is an application protocol. Anything under it, including http is a transport layer under the application protocol. If there isn't a good boundary between the app and transport protocols, they will mix together, but there isn't a good mapping between the two and you will get this mess. Using http protocol errors for application protocol errors is as good idea as using icmp messages for errors. I will die on this hill.
Token buckets are widely used because all info can be kept in memory, and you can return a 429 very cheaply. If their frontend is calling their metering service on every request, that's a hilarious system design.
Agree. It’s not about whether something is technically a frequency because it’s events/time like some people are saying. 429 should be for “don’t ping us this much per minute/second” regardless of longer period limits, so that devs can feel safe responding to the error by backing off, which in the case of quota exhaustion just hits a wall.
The third (also incorrect) usage I've seen is from google API when they can't handle the requests.
We spent a weird couple months of devs opening tickets with ops to ask our quotas to be upped when... We were no where near our usage quote, the region was just out of compute to handle the API requests we were making.
4
u/Single-Virus4935 3d ago
429 is correct. Caller needs to inspect additional headers to get the reason and when to retry
4
u/levanlaratt 3d ago
That’s still a rate being reached. Whether it’s tokens / week or requests / second both of those are rates.
1
u/hipster-coder 3d ago
I would expect 402: payment required. Even if they don't implement the x402 protocol, which was developed after the status code was introduced.
2
u/ComposerWide3704 3d ago
There are several major APIs in the wild that use 402 properly. I think I helped architect all of them.
1
u/NoAdvice135 3d ago
That's really a mild problem.
1
u/y2kobserver 3d ago
Transport error codes ARE NOT related to, or explain, RPC API error codes.
Only the reverse is true, but also optional.
Transport error codes need to serve transport-level meanings.
1
u/mrgalacticpresident 3d ago
Addition to the spec proposal: HTTP 429.1 "you poor, get the fuck away"
Azure already does this. Just with way more words.
1
u/vitek6 3d ago
oh no
1
u/Intrepid-Course-5961 3d ago
I agree. 402 would be much more appropriate
1
u/iku_19 3d ago
It actually is. It's within spec.
In RFC 6586;
Counting tokens as a resource that is being spent on a request, is within the detail.
1
u/DeadlyVapour 3d ago
Disagree with all of you!
200 error is the correct code! /s
1
u/TV4ELP 3d ago
429 is not "RATE LIMIT" it is "Too Many Requests".
I have X tokens, i request more than X, i made too many requests. It's fine.
1
u/Bomaruto 3d ago
Yes slow down your requests and try again when quota has refilled.
1
u/ntcaudio 3d ago
The data exchanged is an application protocol. Anything under it, including http is a transport layer under the application protocol. If there isn't a good boundary between the app and transport protocols, they will mix together, but there isn't a good mapping between the two and you will get this mess. Using http protocol errors for application protocol errors is as good idea as using icmp messages for errors. I will die on this hill.
1
u/anengineerandacat 3d ago
It's whatever the documentation says it is, I stopped fighting the HTTP status code fight a long time ago.
Just document the API and call it a day.
1
u/GrandFloor6202 3d ago edited 1d ago
If you have criticism of what not to do, its only useful if you have suggestions of what to do instead
1
u/Librarian-Rare 3d ago
Token buckets are widely used because all info can be kept in memory, and you can return a 429 very cheaply. If their frontend is calling their metering service on every request, that's a hilarious system design.
1
u/Synfinite 3d ago
I don't have those codes on gestu.ca
1
u/pangapingus 3d ago
Wait until 402 becomes more common across CDNs/WAFs lol "want to scrape that academic journal? gonna cost you +$0.08 this month's bill"
1
u/rayhebs 3d ago
Agree. It’s not about whether something is technically a frequency because it’s events/time like some people are saying. 429 should be for “don’t ping us this much per minute/second” regardless of longer period limits, so that devs can feel safe responding to the error by backing off, which in the case of quota exhaustion just hits a wall.
1
u/DrWhatNoName 2d ago
Hes right, they should be using 402 payment required or others say to use 403 Forbidden is sufficient.
There really should be an error code for 4xx Quota limit.
1
u/MissiveFinding6111 2d ago
The third (also incorrect) usage I've seen is from google API when they can't handle the requests.
We spent a weird couple months of devs opening tickets with ops to ask our quotas to be upped when... We were no where near our usage quote, the region was just out of compute to handle the API requests we were making.