Expose prompt caching stats in metrics telemetry
Context
The Copilot SDK currently does not support prompt caching natively, unlike other LLM solutions (such as the Anthropic or OpenAI APIs). This leads to increased costs and latency when the same prompts are sent multiple times (system prompt, etc...), since every request is always processed as new by the backend.
Request I am requesting the introduction of a prompt caching feature at the SDK level, even if only as an optional capability.
Rationale
Reduced costs and latency for repetitive prompts Alignment with LLM best practices and the example set by other SDKs The ability to develop systems that make heavy reuse of requests in an efficient way
This is so much needed with the new usage-based billing.
Thank you!
The SDK does already enable prompt caching internally, but does not expose fine-grained APIs to SDK users; doing that would be a bit tricky, as how prompt caching works exactly differs significantly across providers. For example, OpenAI largely implements prompt caching internally on the server side, without fine-grained APIs allowing clients to determine what should get cached (Anthropic does).
Is there something specific you're looking for in terms of prompt caching, which model(s) are you using, etc.?
The SDK does already enable prompt caching internally, but does not expose fine-grained APIs to SDK users; doing that would be a bit tricky, as how prompt caching works exactly differs significantly across providers. For example, OpenAI largely implements prompt caching internally on the server side, without fine-grained APIs allowing clients to determine what should get cached (Anthropic does).
Is there something specific you're looking for in terms of prompt caching, which model(s) are you using, etc.?
Hello @roji and thank you for your answer. So the thing is that we cannot control if prompt caching is working or not. I mean, with this new usage based billing, how are we supposed to optimize our prompt and agentic flows without knowing if a prompt is going to hit or miss the cache?
This is also an environmental issue, BIG ISSUE. An agentic app that does everything to hit the cache will be much more nvironment friendly than another one that does not do anything to hit the cache.
As Github Copilot SDK user, I want to know if my app is optimized to hit the cache, and actually this SDK just abstract this aspect without giving us the context to know how to optimize prompt caching.
So the thing is that we cannot control if prompt caching is working or not. I mean, with this new usage based billing, how are we supposed to optimize our prompt and agentic flows without knowing if a prompt is going to hit or miss the cache?
My point above was that low-level prompt caching controls is something that OpenAI itself does not allow (in contrast to Anthropic). The cache operates largely automatically, providing you follow certain guidelines (see the docs). Beyond some very coarse controls which are exposed to the client, that's just how OpenAI works - it's not something that the Copilot SDK can control (we just expose access).
So the thing is that we cannot control if prompt caching is working or not. I mean, with this new usage based billing, how are we supposed to optimize our prompt and agentic flows without knowing if a prompt is going to hit or miss the cache?
My point above was that low-level prompt caching controls is something that OpenAI itself does not allow (in contrast to Anthropic). The cache operates largely automatically, providing you follow certain guidelines (see the docs). Beyond some very coarse controls which are exposed to the client, that's just how OpenAI works - it's not something that the Copilot SDK can control (we just expose access).
I totally undesrtand what your are saying. Sorry for my English I'm not native.
What I expect is at least some informations regarding if the cache was hitted or missed, the official OpanAI API exposes it. At least we could know if we're effectively using the cache or not, allowing us to tweak our agentic flows.
I've changed the issue title to reflect that this is about metrics/telemetry.
Do you think this will be ever implemented?
@LeoX91 I think so, but we have a huge amount of work on our hands, and for now you're the only one requesting it.
Closing as fixed after verification against the current public SDK sources and bundled behavior.
Public evidence
- #1720 — Add usage and billing metrics docs page (merged 2026-07-31)
- commit
8e1cd4b44eeb— Add usage and billing metrics docs page (#1720) nodejs/src/generated/session-events.ts—AssistantUsageData; cacheReadTokens; cacheWriteTokens; cacheExpiresAtdocs/features/streaming-events.md—assistant.usage; cacheReadTokens; cacheWriteTokens; cacheExpiresAtdocs/features/usage-and-billing.md—Per-call token counts; Accumulated AI credit and token totals
The reported behavior/request is implemented at the current SDK baseline, so this issue is being closed as completed.
Public SDK baseline: github/copilot-sdk d5c9d06d8c41.