{"record":{"id":"42ab44b458bec076","repo":"BerriAI/litellm","slug":"prompt-prompt-id-not-found","errorCode":null,"errorMessage":"Prompt '{prompt_id}' not found","messagePattern":"Prompt '(.+?)' not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"critical","filePath":"cookbook/mock_prompt_management_server/mock_prompt_management_server.py","lineNumber":303,"sourceCode":"\n    return {\"prompts\": prompts_list, \"total\": len(prompts_list)}\n\n\n@app.get(\"/prompts/{prompt_id}/variables\")\nasync def get_prompt_variables(\n    prompt_id: str, authorization: Optional[str] = Header(None)\n):\n    \"\"\"\n    Get all variables in a prompt template.\n\n    This is a convenience endpoint (not part of the LiteLLM spec) for\n    discovering what variables a prompt expects.\n    \"\"\"\n    # Verify authentication\n    verify_api_key(authorization)\n\n    if prompt_id not in PROMPTS_DB:\n        raise HTTPException(\n            status_code=status.HTTP_404_NOT_FOUND,\n            detail=f\"Prompt '{prompt_id}' not found\",\n        )\n\n    prompt_data = PROMPTS_DB[prompt_id]\n    variables = set()\n\n    # Extract variables from the prompt template\n    import re\n\n    for message in prompt_data[\"prompt_template\"]:\n        content = message.get(\"content\", \"\")\n        # Find all {variable} patterns\n        found_vars = re.findall(r\"\\{(\\w+)\\}\", content)\n        variables.update(found_vars)\n\n    return {\n        \"prompt_id\": prompt_id,","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/cookbook/mock_prompt_management_server/mock_prompt_management_server.py#L285-L321","documentation":"The client-resolution guard on the retrieve path: retrieve_fine_tuning_job builds a client via get_openai_client(); if it returns None (no api_key argument, no OPENAI_API_KEY environment/secret value, no custom client), this ValueError is raised before any HTTP request. It is a missing-credentials error, local to litellm.","triggerScenarios":"Calling litellm.retrieve_fine_tuning_job(fine_tuning_job_id=...) with no key in the call, module globals, or environment.","commonSituations":"Status-checking scripts run from schedulers (cron, Airflow) that lack the interactive shell's env; key present under a different variable name; secrets injected only into web processes, not the polling job.","solutions":["Ensure OPENAI_API_KEY is exported in the polling process.","Or pass api_key=... to retrieve_fine_tuning_job.","Or pass a prebuilt client via client=."],"exampleFix":"# before\njob = litellm.retrieve_fine_tuning_job(fine_tuning_job_id=\"ftjob-abc\")\n\n# after\njob = litellm.retrieve_fine_tuning_job(fine_tuning_job_id=\"ftjob-abc\", api_key=os.environ[\"OPENAI_API_KEY\"])","handlingStrategy":"validation","validationCode":"import os\n\ndef can_retrieve_jobs(api_key: str | None) -> bool:\n    return bool(api_key or os.environ.get(\"OPENAI_API_KEY\"))","typeGuard":null,"tryCatchPattern":"try:\n    job = litellm.retrieve_fine_tuning_job(fine_tuning_job_id=jid)\nexcept ValueError as e:\n    if \"not initialized\" in str(e):\n        job = litellm.retrieve_fine_tuning_job(fine_tuning_job_id=jid, api_key=os.environ[\"OPENAI_API_KEY\"])\n    else:\n        raise","preventionTips":["Schedulers (cron/Airflow) need the env var explicitly; verify with `env | grep OPENAI` in the job.","Pass api_key explicitly in status-polling code."],"tags":["openai","fine-tuning","authentication","configuration","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}