feat: add Anthropic-compatible AI proxy endpoint
- Create src/lib/anthropic-proxy.ts: accepts Anthropic Messages API format (POST /v1/messages) and routes to the same backend providers - Anthropic model names (claude-sonnet-4, claude-3-haiku, claude-opus-4) map to backend models with full request/response translation - Streaming (SSE) via Anthropic protocol: message_start, content_block_delta, message_stop events - Add /v1/messages route to server with CORS and proxy pool fallback - Reuses MODEL_ROUTES from ai-proxy.ts for consistent backend routing Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
567ed52db5
commit
4168a087a0
+2
-1
@@ -46,7 +46,8 @@ export interface BackendConfig {
|
||||
|
||||
// ─── Model routing table ─────────────────────────────────────────────────────────
|
||||
|
||||
const MODEL_ROUTES: Record<string, BackendConfig> = {
|
||||
/** Map of model name → backend configuration. Exported for reuse by anthropic-proxy. */
|
||||
export const MODEL_ROUTES: Record<string, BackendConfig> = {
|
||||
// ── opencode.ai (OpenAI-compatible — passthrough) ────────────────
|
||||
"deepseek-v4-flash-free": {
|
||||
provider: "opencode",
|
||||
|
||||
Reference in New Issue
Block a user