Skip to content

Support new Claude models via regex pattern matching instead of whitelist #16

@eatnug

Description

@eatnug

Problem

The API rejects usage data for newer Claude models that aren't in the server's whitelist.

Current error:

{"error":{"message":"Usage validation failed: Invalid or unknown model: claude-opus-4-5-20251101"}}

This is the same issue as #15 (claude-sonnet-4-5-20250929), but for Opus 4.5.

Root Cause

The backend appears to maintain a hardcoded list of allowed models. Every time Anthropic releases a new model, the leaderboard stops working until the whitelist is manually updated.

Suggested Solution

Instead of maintaining a whitelist, use regex pattern matching to validate model names:

import re

# Pattern matches: claude-{model}-{version}-{date}
CLAUDE_MODEL_PATTERN = re.compile(
    r'^claude-'                           # prefix
    r'(opus|sonnet|haiku)'                # model family
    r'(-\d+(\.\d+)?)?'                    # optional version (e.g., -4, -4.5, -3-5)
    r'-\d{8}$'                            # date suffix (YYYYMMDD)
)

def is_valid_model(model: str) -> bool:
    return bool(CLAUDE_MODEL_PATTERN.match(model)) or model == 'unknown'

This pattern would match:

  • claude-opus-4-5-20251101
  • claude-sonnet-4-5-20250929
  • claude-sonnet-4-20250514
  • claude-haiku-3-5-20241022
  • gpt-4 (not Claude)
  • random-string

Benefits

  1. Future-proof: New Claude models automatically work
  2. No maintenance: No need to update whitelist for each release
  3. Still secure: Only validates Claude model naming convention

Environment

  • CLI Version: 0.2.9
  • Model: claude-opus-4-5-20251101
  • OS: macOS

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions