paperclipai/paperclip · error · Error
OpenCode returned no models. Run `opencode models` and verif
Error message
OpenCode returned no models. Run `opencode models` and verify provider auth.
What it means
Thrown by ensureOpenCodeModelConfiguredAndAvailable (LOCAL, models.ts) when discovery completes but returns zero models, after the OPENCODE_ALLOW_ALL_MODELS bypass was not set. It tells the operator to run `opencode models` and verify provider auth, because the binary ran but enumerated nothing.
Source
Thrown at packages/adapters/opencode-local/src/server/models.ts:209
// When the caller opts into OPENCODE_ALLOW_ALL_MODELS, OpenCode accepts any
// provider/model at run time (e.g. gateway-routed models that never appear in
// `opencode models` output). Honour that by skipping the availability probe;
// we still enforce the provider/model format above and do not second-guess
// 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 [];
}View on GitHub (pinned to 67001ec6eb)
Solutions
- Run `opencode models` locally and confirm it lists provider/model lines.
- Set a valid provider API key in the env passed to discovery (e.g. ANTHROPIC_API_KEY / OPENAI_API_KEY).
- Run `opencode login` for the relevant provider.
- If the model is gateway-routed and won't appear in the list, set OPENCODE_ALLOW_ALL_MODELS=true to bypass the availability check.
Defensive patterns
Strategy: validation
Validate before calling
const allowAll = isTruthyEnvFlag(normalizeEnv(input.env).OPENCODE_ALLOW_ALL_MODELS ?? process.env.OPENCODE_ALLOW_ALL_MODELS);
if (!allowAll) {
// ensure at least one provider API key is set before calling ensureOpenCodeModelConfiguredAndAvailable
} Try / catch
try {
return await ensureOpenCodeModelConfiguredAndAvailable(input);
} catch (e) {
if (e instanceof Error && /OpenCode returned no models/.test(e.message)) {
// set provider auth or OPENCODE_ALLOW_ALL_MODELS, then retry
}
throw e;
} Prevention
- Set at least one provider API key in the run env.
- Run `opencode models` locally during workspace setup to catch auth gaps early.
- Use OPENCODE_ALLOW_ALL_MODELS for gateway-routed models.
When it happens
Trigger: discoverOpenCodeModelsCached returns [] and env.OPENCODE_ALLOW_ALL_MODELS is not truthy. The model id already passed requireOpenCodeModelId (format ok); the failure is that no provider serves any model.
Common situations: opencode installed and runs but no provider API key is configured; the provider env vars are present but invalid; opencode config has all providers disabled.
Related errors
- OpenCode returned no models on the remote execution target.
- Configured OpenCode model is unavailable on the remote execu
- OpenCode requires `adapterConfig.model` in provider/model fo
- `opencode models` timed out after ${MODELS_DISCOVERY_TIMEOUT
- `opencode models` failed: ${detail}
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/6580be3723c1d29c.
Report an issue: GitHub.