Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

fix(anthropic-map): route opusplan aliases to the default family

Vijay Saib2d2573cf2a0
diff --git a/server/src/__tests__/services/anthropic-map.test.ts b/server/src/__tests__/services/anthropic-map.test.ts
new file mode 100644
index 00000000..ba3fd85f
--- /dev/null
+++ b/server/src/__tests__/services/anthropic-map.test.ts
@@ -0,0 +1,31 @@
+import { describe, it, expect } from 'vitest';
+import { classifyClaudeFamily } from '../../services/anthropic-map.js';
+
+// classifyClaudeFamily maps a requested model alias to a Claude family (or null
+// for a concrete catalog id). Claude Code's planning alias `opusplan` is
+// opus-ish by name, but the operator map has no `opusplan` slot — it must fall
+// through to the `default` family, as the function's own comment states.
+describe('classifyClaudeFamily', () => {
+ it('routes Claude Code opusplan aliases to the default family', () => {
+ expect(classifyClaudeFamily('opusplan')).toBe('default');
+ expect(classifyClaudeFamily('opusplan-4')).toBe('default');
+ expect(classifyClaudeFamily('OpusPlan')).toBe('default');
+ });
+
+ it('still classifies real opus models as the opus family', () => {
+ expect(classifyClaudeFamily('opus')).toBe('opus');
+ expect(classifyClaudeFamily('claude-opus-4-1')).toBe('opus');
+ });
+
+ it('classifies the other Claude families and aliases as before', () => {
+ expect(classifyClaudeFamily('claude-sonnet-4-5')).toBe('sonnet');
+ expect(classifyClaudeFamily('claude-3-5-haiku')).toBe('haiku');
+ expect(classifyClaudeFamily('claude-something-new')).toBe('default');
+ expect(classifyClaudeFamily('')).toBe('default');
+ expect(classifyClaudeFamily('auto')).toBe('default');
+ });
+
+ it('returns null for a non-Claude concrete catalog id', () => {
+ expect(classifyClaudeFamily('llama-3.1-70b')).toBeNull();
+ });
+});
diff --git a/server/src/services/anthropic-map.ts b/server/src/services/anthropic-map.ts
index cdd483ed..2e91c3b6 100644
--- a/server/src/services/anthropic-map.ts
+++ b/server/src/services/anthropic-map.ts
@@ -62,11 +62,14 @@ export function setClaudeModelMap(input: unknown): AnthropicModelMap {
export function classifyClaudeFamily(model?: string): ClaudeFamily | null {
const m = (model ?? '').trim().toLowerCase();
if (!m || m === 'auto' || m === 'default' || m === 'freellmapi-auto') return 'default';
+ // Claude Code's planning alias is opus-ish by name but must hit the catch-all,
+ // so match it before the substring family checks below.
+ if (m === 'opusplan' || m === 'opusplan-4') return 'default';
if (m.includes('opus')) return 'opus';
if (m.includes('sonnet')) return 'sonnet';
if (m.includes('haiku')) return 'haiku';
- // Any other claude-ish alias (incl. Claude Code's opusplan) → the catch-all.
- if (m.startsWith('claude') || m === 'opusplan' || m === 'opusplan-4') return 'default';
+ // Any other claude-ish alias → the catch-all.
+ if (m.startsWith('claude')) return 'default';
return null;
}