Feature Request: Return x-ratelimit-* headers in GitHub Copilot completions API responses
- 主要语言
- Java
- 星标
- 10.5k
- 派生
- 1.5k
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 129
描述
## Summary
GitHub Copilot's OpenAI-compatible completions API does not return `x-ratelimit-*` response headers, making it impossible for API consumers, custom clients, and AI agent frameworks to track token usage, quota consumption, and rate-limit state at runtime.
## Current Behavior
When calling the GitHub Copilot completions API (OpenAI-compatible endpoint), the response contains **no** `x-ratelimit-*` headers:
- `x-ratelimit-limit-requests` — absent
- `x-ratelimit-remaining-requests` — absent
- `x-ratelimit-reset-requests` — absent
- `x-ratelimit-limit-tokens` — absent
- `x-ratelimit-remaining-tokens` — absent
This has been confirmed both via direct API testing and by inspecting session logs from clients that parse these headers. There is also **no REST endpoint** to poll current quota usage (e.g. "how many requests do I have left this hour?") — unlike OpenAI's `/dashboard/billing/usage` or providers like Nous Portal and OpenRouter that return these headers natively.
## Expected Behavior
The completions API should return standard `x-ratelimit-*` headers after every response, consistent with other OpenAI-compatible providers:
```
x-ratelimit-limit-requests: 60
x-ratelimit-remaining-requests: 45
x-ratelimit-reset-requests: 23s
x-ratelimit-limit-tokens: 128000
x-ratelimit-remaining-tokens: 70432
```
## Motivation
1. **AI agent frameworks** parse `x-ratelimit-*` headers to display real-time quota/rate-limit info in status bars and UIs. Without these headers, rate-limit state is always `None` for Copilot sessions, degrading the user experience compared to other providers.
2. **Usage transparency** — developers building on the Copilot API have no programmatic way to know how close they are to their quota limit mid-session. The information simply doesn't exist at runtime.
3. **OpenAI-compatibility** — the API surface implies OpenAI-compatible behaviour. Returning these headers would align Copilot with the de-facto standard that all other OpenAI-compatible providers follow.
## Workaround
None exists for quota transparency at runtime. Switching to Nous Portal, OpenRouter, or OpenAI as provider restores header-based quota tracking immediately.
## Additional Context
- GitHub Copilot enforces quota server-side based on subscription plan.
- This affects any third-party tool, IDE extension, or agent framework that relies on `x-ratelimit-*` headers for adaptive rate limiting or status display (RPM remaining, token budget remaining, reset time).
贡献指南
调研方向
该 issue 未指出任何 repository 文件、测试或入口点;请先查看报告中描述的直接 API 测试和会话日志证据。当 Completions API 在每次响应后都返回所请求的 x-ratelimit-* headers(包括请求和 token 限制、剩余值以及重置信息)时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- github, java
- 领域
- api, backend-api-design
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100