validate_model
Check whether a specified model ID exists in the OpenRouter model list.
Instructions
Check if a model ID exists
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes |
Implementation Reference
- src/tool-handlers/validate-model.ts:6-37 (handler)The handler function that validates whether a model ID exists. It checks for required input, refreshes the model cache if an API client is available, and returns { valid: boolean }.
export async function handleValidateModel( request: { params: { arguments: { model: string } } }, modelCache: ModelCache, apiClient?: OpenRouterAPIClient, ) { const { model } = request.params.arguments ?? { model: '' }; if (!model || typeof model !== 'string') { return toolError(ErrorCode.INVALID_INPUT, 'model is required.'); } if (apiClient) { try { await modelCache.ensureFresh(() => apiClient.getModels()); } catch (error: unknown) { return classifyUpstreamError(error, 'validate_model'); } } if (!modelCache.isValid()) { return toolError(ErrorCode.INTERNAL, 'No model data available.'); } return { content: [ { type: 'text' as const, text: JSON.stringify({ valid: modelCache.has(model) }), }, ], }; } - src/tool-handlers.ts:253-265 (schema)Input schema definition for the validate_model tool. Requires a single 'model' string parameter.
{ name: 'validate_model', description: 'Check if a model ID exists', annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, inputSchema: { type: 'object', properties: { model: { type: 'string' } }, required: ['model'], }, - src/tool-handlers.ts:505-510 (registration)Registration: the switch-case in the tool dispatch that maps the 'validate_model' tool name to the handleValidateModel handler.
case 'validate_model': return handleValidateModel( wrapToolArgs(args as { model: string } | undefined), this.modelCache, this.apiClient, ); - Error classification helper called when fetching models fails during validation.
return classifyUpstreamError(error, 'validate_model');