musistudio/claude-code-router · error · Error

No compatible media API model is available. Select a provide

Error message

No compatible media API model is available. Select a provider model that declares image or video generation support.

What it means

normalizeMediaModelSelector migrates the selector to a currently available media model of the requested kind; if migration returns nothing (no compatible image/video model exists for the selector's provider), this catch-all is thrown. It typically fires for legacy Grok media selectors whose models no longer exist.

Source

Thrown at packages/core/src/media/service.ts:773

  const credential = sortProviderCredentialsForConfig(activeProviderCredentials(provider))[0];
  return {
    model: resolved.model,
    protocol,
    providerBaseUrl: providerBaseUrl.trim(),
    providerName: provider.name,
    providerSelector: credential
      ? providerCredentialInternalName(provider, selectorProtocol, credential)
      : capability || isImportedGrokAgentProvider(provider)
        ? providerCapabilityInternalName(provider, protocol)
        : providerRuntimeId(provider)
  };
}

function normalizeMediaModelSelector(config: AppConfig, selector: string, operation?: MediaOperation): string {
  const kind = operation === "video-generate" ? "video" : "image";
  const migrated = migrateLegacyGrokMediaModelSelector(config.Providers, requiredModelSelector(selector), kind);
  if (!migrated) {
    throw new Error("No compatible media API model is available. Select a provider model that declares image or video generation support.");
  }
  return migrated;
}

function normalizeGatewayTransport(transport: GatewayMediaTransport): GatewayMediaTransport {
  return {
    ...transport,
    baseUrl: transport.baseUrl.replace(/\/+$/g, "")
  };
}

export const mediaService = new MediaService();

export const mediaServiceForTest = {
  isSafeImplicitWorkingDirectory
};

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Update the selector to a currently supported image/video model id
  2. Ensure the provider hosting the replacement model is configured
  3. Remove stale model references from defaults and fallback lists

Example fix

// before
model: "grok-2-image-old"
// after
model: "xai/grok-2-image"
Defensive patterns

Strategy: try-catch

Validate before calling

const migrated = migrateLegacyGrokMediaModelSelector(config.Providers, selector, kind);
if (!migrated) selector = currentDefaultMediaModel(kind);

Type guard

null

Try / catch

try { await call(); } catch (e) { if (e instanceof Error && e.message.includes("No compatible media API model")) return updateModelSelector(); throw e; }

Prevention

When it happens

Trigger: Passing a legacy or removed Grok media model selector for which no migration target of the requested kind is configured.

Common situations: Version upgrades that renamed/removed bundled Grok media models; configs still referencing old selector strings.

Related errors


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/675ee986908b131e. Report an issue: GitHub.