Skip to content

Expose rate-limit headers on successful responses #38

Description

@pavlof01

Context

apps/api/src/rateLimit.ts returns Retry-After and meta.retryAfter on 429, and nothing before that. A client — including our own frontend — cannot tell it is approaching a limit until it is refused, and an API-key holder has no way to pace themselves.

Proposal

  • Emit X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset on successful responses for the bucket the request was charged to.
  • Include the bucket name (general / heavy / trace) so a caller can tell which budget the numbers describe.
  • Document the headers in the OpenAPI document and in the README's rate-limit section.

Acceptance criteria

  • A successful /api/run carries the three headers for the heavy bucket.
  • Values are consistent with the 429 the next request would receive.
  • Covered in app.test.ts via app.inject().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendAPI, sandbox, engine integrationenhancementNew feature or requestgood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions