decolua/9router · error

Invalid model format

Error message

Invalid model format

What it means

HTTP 400 returned when getModelInfo cannot parse a provider out of the `model` string (no `.provider` in the parsed result). The router routes by `provider/model` identifiers, so an unparseable or unknown model string cannot be mapped to any upstream provider.

Source

Thrown at src/sse/handlers/embeddings.js:80

    if (!valid) {
      log.warn("AUTH", "Invalid API key (requireApiKey=true)");
      return errorResponse(HTTP_STATUS.UNAUTHORIZED, "Invalid API key");
    }
  }

  if (!modelStr) {
    log.warn("EMBEDDINGS", "Missing model");
    return errorResponse(HTTP_STATUS.BAD_REQUEST, "Missing model");
  }

  if (!body.input) {
    log.warn("EMBEDDINGS", "Missing input");
    return errorResponse(HTTP_STATUS.BAD_REQUEST, "Missing required field: input");
  }

  const modelInfo = await getModelInfo(modelStr);
  if (!modelInfo.provider) {
    log.warn("EMBEDDINGS", "Invalid model format", { model: modelStr });
    return errorResponse(HTTP_STATUS.BAD_REQUEST, "Invalid model format");
  }

  const { provider, model } = modelInfo;

  if (modelStr !== `${provider}/${model}`) {
    log.info("ROUTING", `${modelStr} → ${provider}/${model}`);
  } else {
    log.info("ROUTING", `Provider: ${provider}, Model: ${model}`);
  }

  // Credential + fallback loop (mirrors handleChat)
  const excludeConnectionIds = new Set();
  let lastError = null;
  let lastStatus = null;

  while (true) {
    const credentials = await getProviderCredentials(provider, excludeConnectionIds, model);

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Prefix the model with a registered provider: `provider/model` (e.g. "openai/text-embedding-3-small")
  2. Check the dashboard model list (or /v1/models) for valid model identifiers
  3. Run the alias/registry regression scripts if you recently changed provider registry files
  4. Use a configured alias/combo name instead of a raw model string

Example fix

// before
{ model: 'text-embedding-3-small', input: ['hi'] }
// after
{ model: 'openai/text-embedding-3-small', input: ['hi'] }
Defensive patterns

Strategy: validation

Validate before calling

const PROVIDERS = ['openai','gemini','voyage','jina']; // from /v1/models or dashboard
function parseModelId(s) {
  const i = s.indexOf('/');
  return i > 0 && PROVIDERS.includes(s.slice(0, i)) ? s : null;
}
if (!parseModelId(model)) throw new Error(`Model must be "provider/model": ${model}`);

Type guard

function isQualifiedModelId(s) {
  return typeof s === 'string' && /^[a-z0-9-]+\/[\w.\-]+$/.test(s);
}

Try / catch

if (res.status === 400 && (await res.text()).includes('Invalid model format')) {
  console.error(`"${model}" is not a routable model id — fetch /v1/models for valid ids`);
}

Prevention

When it happens

Trigger: POST to embeddings with model values like "text-embedding-3-small" (no provider prefix), "foo/bar" where foo is not a registered provider, or a typo'd provider id.

Common situations: Using a bare OpenAI model name copied from OpenAI docs without the router's provider prefix; provider renamed or removed from the registry; alias out of date after upgrading the router.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/4edfd2585dd8f189. Report an issue: GitHub.