YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
reroute all Anthropic frontier models
Louis Beaumont1ee7edf9c5f8
diff --git a/packages/ai-gateway/src/handlers/models.ts b/packages/ai-gateway/src/handlers/models.tsindex b3a26a6d0..1b729cb53 100644--- a/packages/ai-gateway/src/handlers/models.ts+++ b/packages/ai-gateway/src/handlers/models.ts@@ -244,68 +244,6 @@ const CURATED_MODELS: ModelEntry[] = [requires_env: 'OPENAI_API_KEY',},// ── Included with screenpipe ──- {- id: 'claude-opus-5',- object: 'model',- owned_by: 'anthropic',- name: 'Claude Opus 5',- description: 'latest frontier claude model for complex reasoning, coding, and agentic work',- tags: ['premium', 'reasoning', 'new'],- free: false,- context_window: 1000000,- best_for: ['hardest tasks', 'complex analysis', 'agentic coding'],- speed: 'medium',- intelligence: 'highest',- cost_tier: 'medium',- recommended_for: ['chat', 'analysis', 'coding'],- warning: 'frontier-priced ($5/$25 per M tokens). use Sonnet 5 or Auto for high-volume work',- },- {- id: 'claude-opus-4-8',- object: 'model',- owned_by: 'anthropic',- name: 'Claude Opus 4.8',- description: 'most intelligent, best reasoning — latest opus',- tags: ['premium', 'reasoning', 'new'],- free: false,- context_window: 200000,- best_for: ['complex tasks', 'analysis', 'agentic coding'],- speed: 'slow',- intelligence: 'highest',- cost_tier: 'medium',- recommended_for: ['chat', 'analysis', 'coding'],- },- {- id: 'claude-opus-4-7',- object: 'model',- owned_by: 'anthropic',- name: 'Claude Opus 4.7',- description: 'previous opus — still very capable',- tags: ['premium', 'reasoning'],- free: false,- context_window: 200000,- best_for: ['complex tasks', 'analysis', 'agentic coding'],- speed: 'slow',- intelligence: 'highest',- cost_tier: 'medium',- recommended_for: ['chat', 'analysis', 'coding'],- },- {- id: 'claude-opus-4-6',- object: 'model',- owned_by: 'anthropic',- name: 'Claude Opus 4.6',- description: 'previous opus — still very capable',- tags: ['premium', 'reasoning'],- free: false,- context_window: 200000,- best_for: ['complex tasks', 'analysis'],- speed: 'slow',- intelligence: 'highest',- cost_tier: 'very_high',- recommended_for: ['chat', 'analysis'],- warning: 'very expensive — will quickly use your daily limit. use Auto or GPT-5.4 mini for pipes',- },{id: 'claude-sonnet-5',object: 'model',diff --git a/packages/ai-gateway/src/providers/anthropic-proxy.ts b/packages/ai-gateway/src/providers/anthropic-proxy.tsindex 48adbdb2a..a7c4db671 100644--- a/packages/ai-gateway/src/providers/anthropic-proxy.ts+++ b/packages/ai-gateway/src/providers/anthropic-proxy.ts@@ -154,12 +154,12 @@ export async function proxyToAnthropic(console.log('proxyToAnthropic: normalized model', original, '->', body.model);}- // Emergency spend containment: preserve Fable presets and Anthropic-format- // clients, but never send another Fable request to the provider. The+ // Emergency spend containment: preserve Fable/Opus presets and Anthropic-format+ // clients, but serve them with Sonnet. The// OpenAI-compatible route applies the same alias before policy/metering.if (body.model && (- body.model.toLowerCase() === 'claude-fable-5' ||- body.model.toLowerCase().startsWith('claude-fable-5-')+ body.model.toLowerCase().startsWith('claude-fable-') ||+ body.model.toLowerCase().startsWith('claude-opus-'))) {console.log('proxyToAnthropic: emergency model', body.model, '-> claude-sonnet-5');body.model = 'claude-sonnet-5';@@ -320,6 +320,7 @@ export async function listAnthropicModels(.filter((model) => !(model.id.includes('haiku') ||model.id.includes('fable') ||+ model.id.includes('opus') ||model.id.includes('sonnet-4') ||model.id.includes('3-5-sonnet') ||model.id.includes('3-7-sonnet')@@ -341,11 +342,6 @@ export async function listAnthropicModels(*/function getFallbackModels(): { id: string; object: string; created: number; owned_by: string }[] {return [- { id: 'claude-opus-5', object: 'model', created: 1784851200, owned_by: 'anthropic' },{ id: 'claude-sonnet-5', object: 'model', created: 1782864000, owned_by: 'anthropic' },- { id: 'claude-opus-4-8', object: 'model', created: 1738800000, owned_by: 'anthropic' },- { id: 'claude-opus-4-7', object: 'model', created: 1738800000, owned_by: 'anthropic' },- { id: 'claude-opus-4-6', object: 'model', created: 1738800000, owned_by: 'anthropic' },- { id: 'claude-opus-4-5-20251101', object: 'model', created: 1730419200, owned_by: 'anthropic' },];}diff --git a/packages/ai-gateway/src/providers/anthropic.ts b/packages/ai-gateway/src/providers/anthropic.tsindex d0e364349..362d81704 100644--- a/packages/ai-gateway/src/providers/anthropic.ts+++ b/packages/ai-gateway/src/providers/anthropic.ts@@ -566,7 +566,9 @@ export class AnthropicProvider implements AIProvider {async listModels(): Promise<{ id: string; name: string; provider: string }[]> {try {const response = await this.client.models.list();- return response.data.map((model) => ({+ return response.data.filter((model) => !(+ model.id.includes('fable') || model.id.includes('opus')+ )).map((model) => ({id: model.id,name: model.display_name,provider: 'anthropic',@@ -575,16 +577,6 @@ export class AnthropicProvider implements AIProvider {console.error('Failed to fetch Anthropic models:', error);// Fallback to current models when the provider catalog is unavailable.return [- {- id: 'claude-opus-5',- name: 'Claude Opus 5',- provider: 'anthropic',- },- {- id: 'claude-opus-4-8',- name: 'Claude Opus 4.8',- provider: 'anthropic',- },{id: 'claude-sonnet-5',name: 'Claude Sonnet 5',diff --git a/packages/ai-gateway/src/providers/index.ts b/packages/ai-gateway/src/providers/index.tsindex 373b40d6d..e66b0c817 100644--- a/packages/ai-gateway/src/providers/index.ts+++ b/packages/ai-gateway/src/providers/index.ts@@ -13,7 +13,7 @@ import { Env } from '../types';// and cost attribution, so callers transparently receive a current model and we// never send another request to the old Google/OpenRouter/Tinfoil lanes.export const RETIRED_HOSTED_MODEL_FALLBACK = 'gpt-5.6-luna';-export const EMERGENCY_FABLE_FALLBACK = 'claude-sonnet-5';+export const EMERGENCY_ANTHROPIC_FALLBACK = 'claude-sonnet-5';const RETIRED_HOSTED_MODEL_IDS = new Set([// Retired Anthropic shortcuts used by older presets and integrations.@@ -53,12 +53,12 @@ const RETIRED_HOSTED_MODEL_IDS = new Set([*/export function resolveModelAlias(model: string): string {const lower = model.toLowerCase();- // Fable produced an abnormal provider-spend incident on 2026-07-31. Keep- // saved presets working, but serve the substantially cheaper current Claude- // model until cancellation-safe accounting and global breakers are live.- if (lower === 'claude-fable-5' || lower.startsWith('claude-fable-5-')) {- console.log(`[router] emergency hosted model ${model} → ${EMERGENCY_FABLE_FALLBACK}`);- return EMERGENCY_FABLE_FALLBACK;+ // Fable and Opus produced an abnormal provider-spend incident on 2026-07-31.+ // Keep saved presets working, but serve the substantially cheaper current+ // Claude model until cancellation-safe accounting and global breakers are live.+ if (lower.startsWith('claude-fable-') || lower.startsWith('claude-opus-')) {+ console.log(`[router] emergency hosted model ${model} → ${EMERGENCY_ANTHROPIC_FALLBACK}`);+ return EMERGENCY_ANTHROPIC_FALLBACK;}if (isRetiredHostedModel(lower)) {console.log(`[router] retired hosted model ${model} → ${RETIRED_HOSTED_MODEL_FALLBACK}`);diff --git a/packages/ai-gateway/src/test/anthropic-proxy.unit.test.ts b/packages/ai-gateway/src/test/anthropic-proxy.unit.test.tsindex 571df834a..eede1cf45 100644--- a/packages/ai-gateway/src/test/anthropic-proxy.unit.test.ts+++ b/packages/ai-gateway/src/test/anthropic-proxy.unit.test.ts@@ -67,8 +67,8 @@ describe('proxyToAnthropic', () => {expect(capturedHeaders['anthropic-version']).toBe('2023-06-01');expect(capturedHeaders['content-type']).toBe('application/json');- // Verify model is kept in body (unlike Vertex which removes it)- expect(capturedBody.model).toBe('claude-opus-4-6');+ // The direct route keeps a model in the body, after emergency normalization.+ expect(capturedBody.model).toBe('claude-sonnet-5');expect(capturedBody.max_tokens).toBe(1024);// Verify response passthrough@@ -130,7 +130,7 @@ describe('proxyToAnthropic', () => {expect(fullText).toContain('message_stop');});- it('should route Fable requests to Sonnet before calling Anthropic', async () => {+ it('should route Fable and Opus requests to Sonnet before calling Anthropic', async () => {let capturedBody: any = null;globalThis.fetch = async (_url: any, init: any) => {capturedBody = JSON.parse(init.body);@@ -150,6 +150,21 @@ describe('proxyToAnthropic', () => {await proxyToAnthropic(request, 'sk-ant-test-key');expect(capturedBody.model).toBe('claude-sonnet-5');++ capturedBody = null;+ const opusRequest = new Request('http://localhost/v1/messages', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({+ model: 'claude-opus-4-8',+ max_tokens: 100,+ messages: [{ role: 'user', content: 'Hello' }],+ }),+ });++ await proxyToAnthropic(opusRequest, 'sk-ant-test-key');++ expect(capturedBody.model).toBe('claude-sonnet-5');});it('should sanitize nested text.text bug in messages', async () => {@@ -208,7 +223,7 @@ describe('proxyToAnthropic', () => {expect(capturedBody.top_k).toBeUndefined();});- it('strips unsupported sampling parameters for Opus 5', async () => {+ it('routes Opus 5 to Sonnet and strips unsupported sampling parameters', async () => {let capturedBody: any = null;globalThis.fetch = async (_url: any, init: any) => {capturedBody = JSON.parse(init.body);@@ -228,7 +243,7 @@ describe('proxyToAnthropic', () => {}),}), 'sk-ant-test-key');- expect(capturedBody.model).toBe('claude-opus-5');+ expect(capturedBody.model).toBe('claude-sonnet-5');expect(capturedBody.temperature).toBeUndefined();expect(capturedBody.top_p).toBeUndefined();expect(capturedBody.top_k).toBeUndefined();@@ -386,8 +401,8 @@ describe('proxyToAnthropic', () => {await proxyToAnthropic(request, 'sk-ant-test-key');- // Vertex deleted model from body — direct API must keep it- expect(capturedBody.model).toBe('claude-opus-4-6');+ // Vertex deleted model from body — direct API keeps the normalized model.+ expect(capturedBody.model).toBe('claude-sonnet-5');});it('should handle tool use messages correctly', async () => {@@ -488,11 +503,11 @@ describe('listAnthropicModels', () => {const models = await listAnthropicModels('sk-test');- expect(models.length).toBe(2);+ expect(models.length).toBe(1);expect(models[0].id).toBe('claude-sonnet-5');expect(models[0].owned_by).toBe('anthropic');expect(models[0].object).toBe('model');- expect(models.some(m => /fable|haiku|sonnet-4/.test(m.id))).toBe(false);+ expect(models.some(m => /fable|opus|haiku|sonnet-4/.test(m.id))).toBe(false);});it('should return fallback models on API error', async () => {@@ -502,8 +517,8 @@ describe('listAnthropicModels', () => {// Should return fallback listexpect(models.length).toBeGreaterThan(0);- expect(models.some(m => m.id === 'claude-opus-5')).toBe(true);expect(models.some(m => m.id === 'claude-sonnet-5')).toBe(true);+ expect(models.some(m => m.id.includes('opus'))).toBe(false);expect(models.some(m => m.id.includes('haiku'))).toBe(false);});@@ -800,7 +815,7 @@ describe('Backwards compatibility with @YYYYMMDD model IDs', () => {expect(capturedBody.model).toBe('claude-sonnet-5');});- it('proxyToAnthropic should not modify model IDs without @', async () => {+ it('proxyToAnthropic should route exact Opus IDs to Sonnet', async () => {let capturedBody: any = null;globalThis.fetch = async (_url: any, init: any) => {@@ -820,10 +835,10 @@ describe('Backwards compatibility with @YYYYMMDD model IDs', () => {await proxyToAnthropic(request, 'sk-ant-test-key');- expect(capturedBody.model).toBe('claude-opus-4-6');+ expect(capturedBody.model).toBe('claude-sonnet-5');});- it('proxyToAnthropic should handle opus @YYYYMMDD format', async () => {+ it('proxyToAnthropic should normalize and route Opus @YYYYMMDD format', async () => {let capturedBody: any = null;globalThis.fetch = async (_url: any, init: any) => {@@ -843,7 +858,7 @@ describe('Backwards compatibility with @YYYYMMDD model IDs', () => {await proxyToAnthropic(request, 'sk-ant-test-key');- expect(capturedBody.model).toBe('claude-opus-4-5-20251101');+ expect(capturedBody.model).toBe('claude-sonnet-5');});});diff --git a/packages/ai-gateway/src/test/model-alias.unit.test.ts b/packages/ai-gateway/src/test/model-alias.unit.test.tsindex 3640aefba..b973588fc 100644--- a/packages/ai-gateway/src/test/model-alias.unit.test.ts+++ b/packages/ai-gateway/src/test/model-alias.unit.test.ts@@ -4,7 +4,7 @@import { describe, it, expect } from 'bun:test';import {- EMERGENCY_FABLE_FALLBACK,+ EMERGENCY_ANTHROPIC_FALLBACK,resolveModelAlias,RETIRED_HOSTED_MODEL_FALLBACK,} from '../providers';@@ -50,9 +50,16 @@ describe('resolveModelAlias', () => {expect(resolveModelAlias('gemma4-e4b')).toBe('gemma4-e4b');});- it('routes Fable aliases to Sonnet during emergency spend containment', () => {- for (const model of ['claude-fable-5', 'Claude-Fable-5', 'claude-fable-5-20260701']) {- expect(resolveModelAlias(model)).toBe(EMERGENCY_FABLE_FALLBACK);+ it('routes Fable and Opus aliases to Sonnet during emergency spend containment', () => {+ for (const model of [+ 'claude-fable-5',+ 'Claude-Fable-5',+ 'claude-fable-5-20260701',+ 'claude-opus-5',+ 'Claude-Opus-4-8',+ 'claude-opus-4-6-20260205',+ ]) {+ expect(resolveModelAlias(model)).toBe(EMERGENCY_ANTHROPIC_FALLBACK);}});diff --git a/packages/ai-gateway/src/test/openai-models.unit.test.ts b/packages/ai-gateway/src/test/openai-models.unit.test.tsindex 89c9a8de2..3aa8b4a86 100644--- a/packages/ai-gateway/src/test/openai-models.unit.test.ts+++ b/packages/ai-gateway/src/test/openai-models.unit.test.ts@@ -92,9 +92,8 @@ describe('OpenAI API model catalog', () => {TINFOIL_API_KEY: 'tinfoil-test',});for (const id of ids) {- expect(id).not.toMatch(/fable|gemini|gemma|gpt-oss|glm-|kimi-|qwen|llama-4|haiku|sonnet-4/i);+ expect(id).not.toMatch(/fable|opus|gemini|gemma|gpt-oss|glm-|kimi-|qwen|llama-4|haiku|sonnet-4/i);}- expect(ids).toContain('claude-opus-5');expect(ids).toContain('claude-sonnet-5');});@@ -118,9 +117,9 @@ describe('tier locking in /v1/models', () => {const models = await listedFor('logged_in');const sonnet = models.find(m => m.id === 'claude-sonnet-5');const opus = models.find(m => m.id === 'claude-opus-5');- // present (not hidden) and flagged so the app can grey + upsell+ // Sonnet remains visible and locked; Opus is hidden during containment.expect(sonnet?.locked).toBe(true);- expect(opus?.locked).toBe(true);+ expect(opus).toBeUndefined();});it('leaves allowed models unlocked for non-Business', async () => {