@@ -256,22 +256,23 @@ def init():
256256 return
257257
258258 # Interactive prompts
259+ click .echo ("Pick an LLM in `provider/model` LiteLLM format:" )
260+ click .echo (" OpenAI: gpt-5.4-mini, gpt-5.4" )
261+ click .echo (" Anthropic: anthropic/claude-sonnet-4-6, anthropic/claude-opus-4-6" )
262+ click .echo (" Gemini: gemini/gemini-3.1-pro-preview, gemini/gemini-3-flash-preview" )
263+ click .echo (" Others: see https://docs.litellm.ai/docs/providers" )
264+ click .echo ()
259265 model = click .prompt (
260- f"Model (e.g. gpt-5.4-mini, anthropic/claude-sonnet-4-6) [ default: { DEFAULT_CONFIG ['model' ]} ] " ,
266+ f"Model (enter for default { DEFAULT_CONFIG ['model' ]} ) " ,
261267 default = DEFAULT_CONFIG ["model" ],
262268 show_default = False ,
263269 )
264- language = click .prompt (
265- f"Language [default: { DEFAULT_CONFIG ['language' ]} ]" ,
266- default = DEFAULT_CONFIG ["language" ],
270+ api_key = click .prompt (
271+ "LLM API Key (saved to .env, enter to skip)" ,
272+ default = "" ,
273+ hide_input = True ,
267274 show_default = False ,
268- )
269- pageindex_threshold = click .prompt (
270- f"PageIndex threshold (pages) [default: { DEFAULT_CONFIG ['pageindex_threshold' ]} ]" ,
271- default = DEFAULT_CONFIG ["pageindex_threshold" ],
272- type = int ,
273- show_default = False ,
274- )
275+ ).strip ()
275276 # Create directory structure
276277 Path ("raw" ).mkdir (exist_ok = True )
277278 Path ("wiki/sources/images" ).mkdir (parents = True , exist_ok = True )
@@ -290,12 +291,22 @@ def init():
290291 openkb_dir .mkdir ()
291292 config = {
292293 "model" : model ,
293- "language" : language ,
294- "pageindex_threshold" : pageindex_threshold ,
294+ "language" : DEFAULT_CONFIG [ " language" ] ,
295+ "pageindex_threshold" : DEFAULT_CONFIG [ " pageindex_threshold" ] ,
295296 }
296297 save_config (openkb_dir / "config.yaml" , config )
297298 (openkb_dir / "hashes.json" ).write_text (json .dumps ({}), encoding = "utf-8" )
298299
300+ # Write API key to KB-local .env (0600) if the user provided one
301+ if api_key :
302+ env_path = Path (".env" )
303+ if env_path .exists ():
304+ click .echo (".env already exists, skipping write. Add LLM_API_KEY manually if needed." )
305+ else :
306+ env_path .write_text (f"LLM_API_KEY={ api_key } \n " , encoding = "utf-8" )
307+ os .chmod (env_path , 0o600 )
308+ click .echo ("Saved LLM API key to .env." )
309+
299310 # Register this KB in the global config
300311 register_kb (Path .cwd ())
301312
0 commit comments