X-ratelimit Headers Missing

The rate limit headers like x-ratelimit-remaining-tokens and x-ratelimit-remaining-tokens are no longer present in the HTTP api as they are documented to be here.

$> curl https://api.openai.com/v1/chat/completions \
  -D - -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
     "model": "gpt-4",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

HTTP/2 200 
date: Tue, 10 Sep 2024 23:58:08 GMT
content-type: application/json
access-control-expose-headers: X-Request-ID
openai-organization: studiosity
openai-processing-ms: 1032
openai-version: 2020-10-01
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-request-id: req_deaa3616cbd15d33b4db96b3ba74d2b4
cf-cache-status: DYNAMIC
set-cookie: __cf_bm=hYY77LPW86IHCxlt4Ckj5AOaCVUtpjnWSTeqBMAc6dY-1726012688-1.0.1.1-xKRPB4N9yUcQZWhNtNFsM_MRYxNYrxURn92ocgRONgdPcsRREoF.2HAFjD1kntn0bA.CW7rbzxXJqRZ7NSYkPw; path=/; expires=Wed, 11-Sep-24 00:28:08 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
x-content-type-options: nosniff
set-cookie: _cfuvid=BWY.Nq8rNtNHMCHMBH0D.4vGEpR8jzpu.fS6z6IeXm0-1726012688465-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None
server: cloudflare
cf-ray: 8c135d3eeec4a97a-SYD
alt-svc: h3=":443"; ma=86400

{
  "id": "chatcmpl-A652Fhuqsr1kskKe5B63M0eiw3842",
  "object": "chat.completion",
  "created": 1726012687,
  "model": "gpt-4-0613",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This is a test!",
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 5,
    "total_tokens": 18
  },
  "system_fingerprint": null
}

Is there a parameter you need to add to get the rate limit info?

1 Like

I can confirm the problem - it is model specific.

Copying this post’s code to this computer and running:

Headers starting with ‘x-’:
x-ratelimit-limit-requests: 10000
x-ratelimit-limit-tokens: 30000000
x-ratelimit-remaining-requests: 9999
x-ratelimit-remaining-tokens: 29999971
x-ratelimit-reset-requests: 0.006
x-ratelimit-reset-tokens: 0
x-request-id: req_4…
x-content-type-options: nosniff

I ran the same with “gpt-4” alias, “gpt-4-turbo”, “gpt-3.5-turbo”, “gpt-4-0314”:

Headers starting with ‘x-’:
x-request-id: req_c…
x-content-type-options: nosniff

“gpt-4-1106-vision-preview” works, which is enough to verify the bug and strange circumstances of it working (only with vision-passing API?).

They seem to have fixed all of them now.

I don’t know if that was anyone reading this, but if so, thank you

1 Like

Moderations does not return a rate limit header, despite its rather low limit in “usage” compared to completion AI models given per account, apparently independent of any tier elevation.