feat: antropik cache — default anthropic-version, forward cache headers, model features, streaming usage, tests
- Auto-default anthropic-version to 2023-06-01 for prompt caching - Forward cache headers (x-cache, cf-cache-status, age, etc.) from backend - Add features: ["prompt_caching"] to /v1/models response - Extract and report actual usage tokens in streaming message_delta - Track output char count for token estimation when backend omits it - Cache-aware usage reporting: cache_creation_input_tokens, cache_read_input_tokens - Comprehensive tests for cache_control preservation in content blocks & system
This commit is contained in:
+8
-6
@@ -494,15 +494,17 @@ export async function handleRequest(
|
||||
if (url.pathname === "/v1/models" && req.method === "GET") {
|
||||
const authErr = requireAuth(req, env);
|
||||
if (authErr) return authErr;
|
||||
const models = listModels().map((id) => ({
|
||||
id,
|
||||
object: "model",
|
||||
created: Math.floor(Date.now() / 1000),
|
||||
owned_by: "edge-proxy",
|
||||
features: ["prompt_caching"],
|
||||
}));
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
object: "list",
|
||||
data: listModels().map((id) => ({
|
||||
id,
|
||||
object: "model",
|
||||
created: Math.floor(Date.now() / 1000),
|
||||
owned_by: "edge-proxy",
|
||||
})),
|
||||
data: models,
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
|
||||
Reference in New Issue
Block a user