{"record":{"id":"ad2f5c08c565db27","repo":"sipeed/picoclaw","slug":"no-models-returned-by-s","errorCode":null,"errorMessage":"no models returned by %s","messagePattern":"no models returned by (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/model/add.go","lineNumber":109,"sourceCode":"\tstdout    io.Writer\n}\n\nfunc runAdd(opt addOptions) error {\n\tif opt.modelType != \"\" && opt.modelType != \"openai-compatible\" {\n\t\treturn fmt.Errorf(\"unsupported --type %q (only 'openai-compatible' is supported)\", opt.modelType)\n\t}\n\tif opt.alias == \"\" {\n\t\topt.alias = defaultAliasName\n\t}\n\n\tselected := opt.modelID\n\tif selected == \"\" {\n\t\tentries, err := fetchOpenAIModels(opt.apiBase, opt.apiKey)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"fetch models: %w\", err)\n\t\t}\n\t\tif len(entries) == 0 {\n\t\t\treturn fmt.Errorf(\"no models returned by %s\", opt.apiBase)\n\t\t}\n\t\tselected, err = pickModel(opt.stdin, opt.stdout, entries)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn upsertModelDefault(opt.apiBase, opt.apiKey, opt.alias, selected, opt.stdout)\n}\n\nfunc pickModel(stdin io.Reader, stdout io.Writer, entries []modelEntry) (string, error) {\n\tfmt.Fprintf(stdout, \"\\n%d model(s) available:\\n\", len(entries))\n\tfor i, m := range entries {\n\t\tline := m.ID\n\t\tif m.Name != \"\" && m.Name != m.ID {\n\t\t\tline = fmt.Sprintf(\"%s (%s)\", m.ID, m.Name)\n\t\t}\n\t\tfmt.Fprintf(stdout, \"  %3d) %s\\n\", i+1, line)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/model/add.go#L91-L127","documentation":"picoclaw model add reached the provider's /models endpoint successfully, but the parsed list was empty. The parser deliberately treats both {\"data\":[]} and bare [] as valid empty results, so this means the server genuinely reported zero models — the interactive picker cannot be built from an empty list. Only hit when -m/--model is omitted.","triggerScenarios":"Provider returns an empty list — common before billing is set up, with keys scoped to no models, or on self-hosted servers (vLLM/ollama-compatible) started with no models loaded; a wrong --api-base pointing at a valid-but-empty endpoint version.","commonSituations":"Freshly created API accounts with no payment method; keys restricted to specific models with none allow-listed; gateways with no models routed; wrong base path hitting a stub endpoint.","solutions":["Skip the listing: picoclaw model add -b <base> -k <key> -m <model-id> -n <alias>","Inspect the raw response with curl <api-base>/models to confirm the list is really empty","On the provider side: add a payment method, fix key scopes, or load models on the self-hosted server","Double-check --api-base points at the prefix that actually serves your models"],"exampleFix":"# before\n$ picoclaw model add -b https://gateway.example.com/v1 -k sk-...\nno models returned by https://gateway.example.com/v1\n\n# after\n$ picoclaw model add -b https://gateway.example.com/v1 -k sk-... -m deepseek-r1-250120 -n deepseek","handlingStrategy":"validation","validationCode":"entries, err := fetchOpenAIModels(apiBase, apiKey)\nif err != nil {\n  return err\n}\nif len(entries) == 0 {\n  return fmt.Errorf(\"no models returned by %s; pass -m <model-id> to add one anyway\", apiBase)\n}","typeGuard":"func isNoModelsError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"no models returned by\")\n}","tryCatchPattern":"if err := runAdd(opt); err != nil {\n  if isNoModelsError(err) {\n    // re-run with -m <known-model-id> to bypass the empty listing\n  }\n  return err\n}","preventionTips":["Pin the model with -m in automation so the flow never depends on /models","Verify provider billing/key scopes — empty lists usually mean account setup, not picoclaw","On self-hosted servers, confirm models are loaded before adding"],"tags":["model","cli","http","config"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}