mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:38:27 +00:00
OpenRouter: allow any model ID instead of restricting to static catalog (#14312)
* OpenRouter: allow any model ID instead of restricting to static catalog OpenRouter models were restricted to a hardcoded prefix list in the internal model catalog, preventing use of newly added or less common models. This change makes OpenRouter work as the pass-through proxy it is -- any valid OpenRouter model ID now resolves dynamically. Fixes https://github.com/openclaw/openclaw/issues/5241 Changes: - Add OpenRouter as an implicit provider in resolveImplicitProviders so models.json is populated when an API key is detected (models-config.providers.ts) - Add a pass-through fallback in resolveModel that creates OpenRouter models on-the-fly when they aren't pre-registered in the local catalog ( model.ts ) - Remove the static prefix filter for OpenRouter/opencode in isModernModelRef (live-model-filter.ts) * Apply requested change for maxTokens * Agents: remove dead helper in live model filter * Changelog: note Joly0/main OpenRouter fix * Changelog: fix OpenRouter entry text --------- Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
@@ -33,10 +33,6 @@ function matchesExactOrPrefix(id: string, values: string[]): boolean {
|
||||
return values.some((value) => id === value || id.startsWith(value));
|
||||
}
|
||||
|
||||
function matchesAny(id: string, values: string[]): boolean {
|
||||
return values.some((value) => id.includes(value));
|
||||
}
|
||||
|
||||
export function isModernModelRef(ref: ModelRef): boolean {
|
||||
const provider = ref.provider?.trim().toLowerCase() ?? "";
|
||||
const id = ref.id?.trim().toLowerCase() ?? "";
|
||||
@@ -89,15 +85,9 @@ export function isModernModelRef(ref: ModelRef): boolean {
|
||||
}
|
||||
|
||||
if (provider === "openrouter" || provider === "opencode") {
|
||||
return matchesAny(id, [
|
||||
...ANTHROPIC_PREFIXES,
|
||||
...OPENAI_MODELS,
|
||||
...CODEX_MODELS,
|
||||
...GOOGLE_PREFIXES,
|
||||
...ZAI_PREFIXES,
|
||||
...MINIMAX_PREFIXES,
|
||||
...XAI_PREFIXES,
|
||||
]);
|
||||
// OpenRouter/opencode are pass-through proxies; accept any model ID
|
||||
// rather than restricting to a static prefix list.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user