{"record":{"id":"7a445b90761fd219","repo":"can1357/oh-my-pi","slug":"kimi-search-credentials-not-found-kimi-web-search","errorCode":null,"errorMessage":"Kimi search credentials not found. Kimi web search uses the Kimi Code service (api.kimi.com); set MOONSHOT_SEARCH_API_KEY / KIMI_SEARCH_API_KEY to a Kimi Code Console key, or login with 'omp /login kimi-code'. A Moonshot Open Platform key (MOONSHOT_API_KEY) is not accepted here.","messagePattern":"Kimi search credentials not found\\. Kimi web search uses the Kimi Code service \\(api\\.kimi\\.com\\); set MOONSHOT_SEARCH_API_KEY / KIMI_SEARCH_API_KEY to a Kimi Code Console key, or login with 'omp /login kimi-code'\\. A Moonshot Open Platform key \\(MOONSHOT_API_KEY\\) is not accepted here\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/web/search/providers/kimi.ts","lineNumber":150,"sourceCode":"\t\tconst classified = classifyProviderHttpError(\"kimi\", response.status, errorText);\n\t\tif (classified) throw classified;\n\t\tthrow new SearchProviderError(\n\t\t\t\"kimi\",\n\t\t\t`Kimi search API error (${response.status}): ${errorText}`,\n\t\t\tresponse.status,\n\t\t);\n\t}\n\n\tconst data = (await response.json()) as KimiSearchResponse;\n\tconst requestId = response.headers.get(\"x-request-id\") ?? response.headers.get(\"x-msh-request-id\") ?? undefined;\n\treturn { response: data, requestId };\n}\n\n/** Execute Kimi web search. */\nexport async function searchKimi(params: KimiSearchParams): Promise<SearchResponse> {\n\tconst keyOrResolver = await resolveKey(params.authStorage, params.sessionId, params.signal);\n\tif (!keyOrResolver) {\n\t\tthrow new Error(\n\t\t\t\"Kimi search credentials not found. Kimi web search uses the Kimi Code service (api.kimi.com); set MOONSHOT_SEARCH_API_KEY / KIMI_SEARCH_API_KEY to a Kimi Code Console key, or login with 'omp /login kimi-code'. A Moonshot Open Platform key (MOONSHOT_API_KEY) is not accepted here.\",\n\t\t);\n\t}\n\n\tconst parsed = params.parsedQuery ?? parseSearchQuery(params.query);\n\tconst query = parsed.hasDirectives ? formatQuery(parsed, KIMI_QUERY_SYNTAX) : params.query;\n\tconst limit = clampNumResults(params.num_results, DEFAULT_NUM_RESULTS, MAX_NUM_RESULTS);\n\tconst { response, requestId } = await withAuth(\n\t\tkeyOrResolver,\n\t\tkey =>\n\t\t\tcallKimiSearch(key, {\n\t\t\t\tquery,\n\t\t\t\tlimit,\n\t\t\t\tincludeContent: params.include_content ?? false,\n\t\t\t\tsignal: params.signal,\n\t\t\t\ttimeoutMs: params.timeoutMs,\n\t\t\t\tfetch: params.fetch,\n\t\t\t}),","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/web/search/providers/kimi.ts#L132-L168","documentation":"Thrown by searchKimi when no usable Kimi search credential can be resolved from auth storage or environment. Kimi web search requires a Kimi Code Console key (MOONSHOT_SEARCH_API_KEY / KIMI_SEARCH_API_KEY or 'omp /login kimi-code'); a regular Moonshot Open Platform key (MOONSHOT_API_KEY) is deliberately not accepted because the search API lives on the Kimi Code service.","triggerScenarios":"searchKimi called with resolveKey returning null — no MOONSHOT_SEARCH_API_KEY/KIMI_SEARCH_API_KEY in env, no stored credential for the session, and no logged-in kimi-code account.","commonSituations":"User set only MOONSHOT_API_KEY (wrong service); fresh machine without 'omp /login kimi-code'; CI environment lacking the search-specific env var; credential expired or scoped to another session.","solutions":["Set MOONSHOT_SEARCH_API_KEY or KIMI_SEARCH_API_KEY to a Kimi Code Console key","Run 'omp /login kimi-code' to store credentials interactively","Do not reuse MOONSHOT_API_KEY — obtain a console key from the Kimi Code service","Check the auth storage for an expired/missing entry and re-login"],"exampleFix":"// before\nexport MOONSHOT_API_KEY=sk-...   # platform key — not accepted\n// after\nexport MOONSHOT_SEARCH_API_KEY=kimi-code-console-key  # or: omp /login kimi-code","handlingStrategy":"validation","validationCode":"// check credential availability before calling\nconst key = process.env.MOONSHOT_SEARCH_API_KEY ?? process.env.KIMI_SEARCH_API_KEY;\nif (!key && !isLoggedIn('kimi-code')) {\n  console.error('Set MOONSHOT_SEARCH_API_KEY or run: omp /login kimi-code');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await searchKimi({ query, authStorage });\n} catch (err) {\n  if (err.message.includes('credentials not found')) {\n    // prompt user to run 'omp /login kimi-code' or set the env var\n  } else throw err;\n}","preventionTips":["Set MOONSHOT_SEARCH_API_KEY (Kimi Code Console key) in your shell profile","Run 'omp /login kimi-code' once per machine","Do not confuse MOONSHOT_API_KEY (platform) with the search key","Document the credential requirement in onboarding/CI setup"],"tags":["authentication","credentials","env-var","kimi"],"backgroundTag":"missing-api-key","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}