feat: anthropic cache support — preserve cache_control, forward anthropic-version header, report real usage tokens
- Add anthropicPassthrough flag to BackendConfig for native Anthropic backends - Preserve cache_control on content blocks and system prompt (keep structured) - Extract and forward anthropic-version header from client to backend - Report actual token usage from backend response (input_tokens, output_tokens) - Support native Anthropic passthrough (no translation) for compatible backends - Wire anthropic-version through all entry points: index.ts, router.ts, worker.ts
This commit is contained in:
@@ -46,6 +46,13 @@ export interface BackendConfig {
|
||||
adaptResponse?: (raw: unknown, req: OpenAIRequest) => unknown;
|
||||
/** Transform a backend SSE/stream line into OpenAI SSE line (or null to skip) */
|
||||
adaptStreamLine?: (line: string, req: OpenAIRequest) => string | null;
|
||||
/** When true, the backend natively supports Anthropic Messages API format.
|
||||
* The proxy will pass through the Anthropic request directly without
|
||||
* translating to OpenAI format. Requires anthropicPassthroughRequest to be set. */
|
||||
anthropicPassthrough?: boolean;
|
||||
/** Optional function to transform an Anthropic request for a native-Anthropic backend.
|
||||
* Only used when anthropicPassthrough is true. Can add/modify headers, body fields, etc. */
|
||||
anthropicPassthroughRequest?: (body: unknown, model: string) => { body: unknown; headers?: Record<string, string> };
|
||||
}
|
||||
|
||||
// --- Shared aichat.org backend config (all models use the same backend) ------
|
||||
|
||||
Reference in New Issue
Block a user