paperclipai/paperclip · error · Error

Configured OpenCode model is unavailable: ${model}. Availabl

Error message

Configured OpenCode model is unavailable: ${model}. Available models: ${sample}

What it means

Thrown by ensureOpenCodeModelConfiguredAndAvailable (LOCAL) when discovery returned models but adapterConfig.model is not among them. Up to 12 available ids are sampled in the message. This is the local sibling of the remote availability error (391).

Source

Thrown at packages/adapters/opencode-local/src/server/models.ts:214

  // the configured model. Prefer the explicit run env, then the process env.
  const env = normalizeEnv(input.env);
  if (isTruthyEnvFlag(env.OPENCODE_ALLOW_ALL_MODELS ?? process.env.OPENCODE_ALLOW_ALL_MODELS)) {
    return [{ id: model, label: model }];
  }

  const models = await discoverOpenCodeModelsCached({
    command: input.command,
    cwd: input.cwd,
    env: input.env,
  });

  if (models.length === 0) {
    throw new Error("OpenCode returned no models. Run `opencode models` and verify provider auth.");
  }

  if (!models.some((entry) => entry.id === model)) {
    const sample = models.slice(0, 12).map((entry) => entry.id).join(", ");
    throw new Error(
      `Configured OpenCode model is unavailable: ${model}. Available models: ${sample}${models.length > 12 ? ", ..." : ""}`,
    );
  }

  return models;
}

export async function listOpenCodeModels(): Promise<AdapterModel[]> {
  try {
    return await discoverOpenCodeModelsCached();
  } catch {
    return [];
  }
}

export function resetOpenCodeModelsCacheForTests() {
  discoveryCache.clear();
}

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Change adapterConfig.model to one of the ids in the Available models sample.
  2. Authenticate the provider that serves the configured model.
  3. Set OPENCODE_ALLOW_ALL_MODELS=true if the model is valid but hidden from enumeration.
Defensive patterns

Strategy: validation

Validate before calling

function modelAvailable(model: string, models: { id: string }[]): boolean {
  return models.some(m => m.id === model);
}

Try / catch

try {
  return await ensureOpenCodeModelConfiguredAndAvailable(input);
} catch (e) {
  if (e instanceof Error && /Configured OpenCode model is unavailable/.test(e.message)) {
    // extract Available models from the message, update adapterConfig.model, retry
  }
  throw e;
}

Prevention

When it happens

Trigger: models.length > 0 AND !models.some(e => e.id === model) during local discovery; OPENCODE_ALLOW_ALL_MODELS not set.

Common situations: Configured model id typo; provider authenticated but the specific model is deprecated/renamed; model belongs to a provider that is not the one authenticated.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/014f5eb9e8f7d7b8. Report an issue: GitHub.