# Possible to check API rate limit headers without burning a request?

**URL:** <https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041>\
**Category:** Feedback\
**Tags:** api, gpt-4-vision\
**Created:** [November 17, 2023, 3:14pm UTC](https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041 "2023-11-17T15:14:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![swillison](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/swillison/32/252101_2.png) [@swillison](https://community.openai.com/u/swillison)\
**Post date:** [November 17, 2023, 3:14pm UTC](https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041/1 "2023-11-17T15:14:08Z")

</div>

I’d like to tell my user how many requests they have left before they start running a bulk API task.

The best information on remaining rate limits is the information returned by the various `x-ratelimit-limit-requests` headers - but those headers are only available if you first run a request against the model in question.

Since `gpt-4-vision-preview` is currently limited to 100 requests a day I don’t want to have to make a call against it just to figure out what remaining request limit I can show my user!

Is there a way to get back those rate limit headers without spending a request? If not, could one be added?

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [November 17, 2023, 4:18pm UTC](https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041/2 "2023-11-17T16:18:54Z")

</div>

Python? The fast answer:

`apiresponse = client.chat.completions.with_raw_response.create(...`

Then you can use `apiresponse.headers.get('x-ratelimit-...')` to get an element from a list of tuples.

Example dump of keys:

```auto

for i in apiresponse.headers:
    print(i)

    
date
content-type
transfer-encoding
connection
access-control-allow-origin
cache-control
openai-model
openai-organization
openai-processing-ms
openai-version
strict-transport-security
x-ratelimit-limit-requests
x-ratelimit-limit-tokens
x-ratelimit-limit-tokens_usage_based
x-ratelimit-remaining-requests
x-ratelimit-remaining-tokens
x-ratelimit-remaining-tokens_usage_based
x-ratelimit-reset-requests
x-ratelimit-reset-tokens
x-ratelimit-reset-tokens_usage_based
x-request-id
cf-cache-status
set-cookie
server
cf-ray
alt-svc

```

The rate limit, though, is being consumed at 2 requests per successful vision, and 1 even on failure, and has a strange reset policy, like you are back to 200 after a few hours after a handful based on tokens.

Then you have to extract the normal reply object within your `response = apiresponse.parse()` similar to normal object pydantic model operations for the new python, but that complicates things like streaming.

---

<div class="post-metadata">

**Author:** ![swillison](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/swillison/32/252101_2.png) [@swillison](https://community.openai.com/u/swillison)\
**Post date:** [November 17, 2023, 4:22pm UTC](https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041/3 "2023-11-17T16:22:40Z")

</div>

That still burns a request in order to read the rate limit headers. I want to be able to read those rate limit headers without decrementing my available requests for the day by one (especially for vision).

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [November 17, 2023, 5:18pm UTC](https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041/4 "2023-11-17T17:18:50Z")

</div>

That is not “burning” if you obtain header values at the same time as you get a vision request fulfilled.

It doesn’t get your current status hours or a day later, though.

---

<div class="post-metadata">

**Author:** ![swillison](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/swillison/32/252101_2.png) [@swillison](https://community.openai.com/u/swillison)\
**Post date:** [November 17, 2023, 5:53pm UTC](https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041/5 "2023-11-17T17:53:21Z")

</div>

I want to show my user a message that says “You have 94 images left today, which resets in 14 hours” - before they have processed any images.

I would like access to those numbers without having to first send a request through the vision API to get them, which would burn one of those daily requests.

---

<div class="post-metadata">

**Author:** ![grandell1234](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/grandell1234/32/286916_2.png) [@grandell1234](https://community.openai.com/u/grandell1234)\
**Post date:** [May 28, 2024, 5:59pm UTC](https://community.openai.com/t/possible-to-check-api-rate-limit-headers-without-burning-a-request/510041/6 "2024-05-28T17:59:28Z")

</div>

Closed on May 28, 2024, 5:59pm UTC


