anthropics / anthropic-sdk-typescript

Access to Anthropic's safety-first language model APIs
https://www.npmjs.com/package/@anthropic-ai/sdk
MIT License
505 stars 49 forks source link

API calls missing Rate Limit Response Headers #450

Open johnmangan opened 1 week ago

johnmangan commented 1 week ago

The documentation on Rate Limits suggests we can see current usage and limits per API request by reading a set of Response Headers. https://docs.anthropic.com/en/api/rate-limits#response-headers

This repository's README tells us how to read Response Headers. https://github.com/anthropics/anthropic-sdk-typescript?tab=readme-ov-file#accessing-raw-response-data-eg-headers

I have tried to make trivial calls, the same as shown in the Response Headers example, with both asResponse and withResponse. Both return the generated message, but neither is including the Rate Limit headers. The only headers either is returning are:

 [
  'cf-cache-status',
  'cf-ray',
  'connection',
  'content-encoding',
  'content-type',
  'date',
  'request-id',
  'server',
  'transfer-encoding',
  'via',
  'x-cloud-trace-context'
]

I have also tried this with both a Haiku model and an Opus model, neither returning the rate limit headers.