{"record":{"id":"75c8025d40fab81f","repo":"BerriAI/litellm","slug":"prompt-prompt-id-not-found-available-prompts","errorCode":null,"errorMessage":"Prompt '{prompt_id}' not found. Available prompts: {list(PROMPTS_DB.keys())}","messagePattern":"Prompt '(.+?)' not found\\. Available prompts: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"cookbook/mock_prompt_management_server/mock_prompt_management_server.py","lineNumber":239,"sourceCode":"\n    Raises:\n        HTTPException: 401 if authentication fails, 404 if prompt not found\n    \"\"\"\n    # Verify authentication\n    verify_api_key(authorization)\n\n    # Log the request parameters (useful for debugging)\n    print(f\"Fetching prompt: {prompt_id}\")\n    if project_name:\n        print(f\"  Project: {project_name}\")\n    if slug:\n        print(f\"  Slug: {slug}\")\n    if version:\n        print(f\"  Version: {version}\")\n\n    # Check if prompt exists\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. Available prompts: {list(PROMPTS_DB.keys())}\",\n        )\n\n    # Get the prompt from the database\n    prompt_data = PROMPTS_DB[prompt_id]\n\n    # Optional: Apply filtering based on project_name, slug, or version\n    # In a real implementation, you might use these to filter prompts by access control\n    # or to fetch specific versions from your database\n\n    return PromptResponse(**prompt_data)\n\n\n@app.get(\"/health\")\nasync def health_check():\n    \"\"\"Health check endpoint\"\"\"\n    return {","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/cookbook/mock_prompt_management_server/mock_prompt_management_server.py#L221-L257","documentation":"The async-client type guard on the list path: when _is_async=True, list_fine_tuning_jobs requires the resolved client to be AsyncOpenAI or AsyncAzureOpenAI. Passing a synchronous OpenAI client (or resolving one) triggers this ValueError before the awaited list call, preventing a runtime 'object is not awaitable' failure. Local type mismatch only.","triggerScenarios":"Calling await litellm.alist_fine_tuning_jobs(...) (or the async branch) with client=OpenAI(...), or in a context where a sync client is resolved for the async path.","commonSituations":"Async dashboards reusing sync client singletons; upgrading sync polling loops to asyncio without changing client instantiation; generic client factory helpers that always return sync clients.","solutions":["Pass AsyncOpenAI(...) instead of OpenAI(...) for async listing.","Or remove the custom client and rely on OPENAI_API_KEY so litellm builds the async client.","Or keep the sync list_fine_tuning_jobs() call."],"exampleFix":"# before\njobs = await litellm.alist_fine_tuning_jobs(limit=20, client=OpenAI())\n\n# after\njobs = await litellm.alist_fine_tuning_jobs(limit=20, client=AsyncOpenAI())","handlingStrategy":"type-guard","validationCode":"from openai import AsyncOpenAI\n\ndef is_async_list_client(client: object) -> bool:\n    return isinstance(client, AsyncOpenAI)","typeGuard":"from openai import AsyncOpenAI, AsyncAzureOpenAI\n\ndef is_usable_async_client(client: object) -> bool:\n    return isinstance(client, (AsyncOpenAI, AsyncAzureOpenAI))","tryCatchPattern":"try:\n    jobs = await litellm.alist_fine_tuning_jobs(limit=20, client=client)\nexcept ValueError as e:\n    if \"AsyncOpenAI\" in str(e):\n        from openai import AsyncOpenAI\n        jobs = await litellm.alist_fine_tuning_jobs(limit=20, client=AsyncOpenAI())\n    else:\n        raise","preventionTips":["Async dashboards should construct clients with AsyncOpenAI in application startup.","Guard shared client singletons with isinstance checks before async use."],"tags":["openai","fine-tuning","async","type-mismatch","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}