Skip to content

matchesModel

The same model can have different IDs depending on the source. Benchmark data might use "claude-sonnet-4-5-20250224", models.dev uses "claude-sonnet-4-5", and OpenRouter uses "anthropic/claude-sonnet-4.5". A simple string comparison would miss these matches. matchesModel() normalizes both IDs (strips provider prefixes, date suffixes, dots vs hyphens, and case) before comparing, so you can match model IDs across sources without writing your own normalization.

function matchesModel(id: string, target: string): boolean
ParameterTypeDescription
idstringThe model ID to check.
targetstringThe target ID to match against.

boolean: true if the IDs refer to the same model. Handles provider prefix differences and case normalization.

import { matchesModel } from "pickai";
// Match despite provider prefix
matchesModel("anthropic/claude-sonnet-4.5", "claude-sonnet-4-5"); // true
// Case-insensitive
matchesModel("GPT-4o", "gpt-4o"); // true

Useful when you have a model ID from a config file, API response, or user input and need to find it in your catalog.