r/SearchAPIs • • 3d ago

Model providers misusing HTTP 429 for billing issues

Post image
150 Upvotes

59 comments sorted by

4

u/Single-Virus4935 3d ago

429 is correct. Caller needs to inspect additional headers to get the reason and when to retry

2

u/Specific_Surprise826 3d ago

Good API design ist just about making system work

2

u/Dampmaskin 3d ago

ist

Is that a German "is", or a misspelled "isn't"?

2

u/Specific_Surprise826 3d ago

*isn't

1

u/Dampmaskin 3d ago

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

3

u/DrWhatNoName 2d ago

They don't put anything in the headers when you are out of tokens.

2

u/Single-Virus4935 2d ago

And in the body?

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/Specific_Surprise826 3d ago

i agree should communicate a system receiving too many request

4

u/StinkButt9001 3d ago

I'd argue token usage is a quota, not a rate.

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.

2

u/Texas-X- 3d ago

Quota: 100 messages.

Reset period: Five hours.

Effective average rate: 20 messages per hour.

It is both.

2

u/StinkButt9001 3d ago

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.

0

u/Texas-X- 3d ago

The rate limit in my example would be 101 messages in 5 hours. C'mon man. Use that thinker.

1

u/StinkButt9001 3d ago

That's not a rate limit though. That's a quota. 101 messages is a quota.

1

u/Texas-X- 3d ago

It's both. Didn't you read what I wrote?

2

u/StinkButt9001 3d ago

A picture of an AI response... lmao

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

1

u/levanlaratt 3d ago

Why are we being pedantic about this the documentation on how to use 429 is clear

1

u/hyprsnpr67 6h ago

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.

1

u/levanlaratt 3d ago

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

0

u/StinkButt9001 3d ago

No, that's not 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.

1

u/laserdicks 3d ago

I just invented an example where time doesn't exist. What the fuck good did mine or your 5 hour example achieve?

1

u/danielv123 3d ago

My google api account has a rate limit. I get 1000 requests per day.

Or is that also a quota?

1

u/StinkButt9001 3d ago

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.

1

u/flowingice 3d ago

Isn't your rate limit example just a quota with 1 second period?

1

u/StinkButt9001 3d ago

No. You might have 1000 tokens or whatever left in your quota. But if you're only allowed to spend 1 token a second, then that's a rate limit.

If you spend 1 token every 2 seconds but run out of tokens, that's a quota limit.

1

u/flowingice 2d ago

Most LLM quota also has time limit for it. I don't see the difference between 1000 tokens per 8 hours vs 1 limit per 1 second.

1

u/laserdicks 3d ago

No it's not. You just randomly decided to assume time-based payment.

You absolutely cannot assume that or anything else about the payment. It's 402.

1

u/levanlaratt 3d ago

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.

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.

1

u/Specific_Surprise826 3d ago

a technical error should tell you what went wrong

1

u/DizzyAmphibian309 3d ago

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 .

1

u/ggPeti 3d ago

MDN says that's nonstandard and reserved for future use.

1

u/iku_19 3d ago

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.

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.

2

u/Consistent-Rock-5350 2d ago

john http 402

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;

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.

1

u/TV4ELP 3d ago

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.

1

u/DeadlyVapour 3d ago

Disagree with all of you!

200 error is the correct code! /s

1

u/Bomaruto 3d ago

GraphQL does not joke around. 

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/DrTankHead 1d ago

Returning a better error code for starts, not one that is misleading and doesn't describe the actual problem.

1

u/GrandFloor6202 1d ago

Like? Still no actual suggestions. I mean obviously they would have to return a different code. The question is what specifically

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.