{"record":{"id":"e78533b7c51259a0","repo":"BerriAI/litellm","slug":"only-admins-can-create-orgs-your-role-is-user","errorCode":null,"errorMessage":"Only admins can create orgs. Your role is = {user_api_key_dict.user_role}","messagePattern":"Only admins can create orgs\\. Your role is = (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"litellm/proxy/management_endpoints/organization_endpoints.py","lineNumber":396,"sourceCode":"        \"budget_id\": \"428eeaa8-f3ac-4e85-a8fb-7dc8d7aa8689\"\n    }'\n    ```\n    \"\"\"\n\n    from litellm.proxy.proxy_server import (\n        litellm_proxy_admin_name,\n        llm_router,\n        prisma_client,\n    )\n\n    if prisma_client is None:\n        raise HTTPException(\n            status_code=500,\n            detail={\"error\": CommonProxyErrors.db_not_connected_error.value},\n        )\n\n    if user_api_key_dict.user_role is None or user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:\n        raise HTTPException(\n            status_code=401,\n            detail={\"error\": f\"Only admins can create orgs. Your role is = {user_api_key_dict.user_role}\"},\n        )\n\n    if llm_router is None:\n        raise HTTPException(status_code=500, detail={\"error\": CommonProxyErrors.no_llm_router.value})\n\n    # Validate budget values are not negative\n    if data.max_budget is not None and (not math.isfinite(data.max_budget) or data.max_budget < 0):\n        raise HTTPException(\n            status_code=400,\n            detail={\"error\": f\"max_budget must be a non-negative finite number. Received: {data.max_budget}\"},\n        )\n    if data.soft_budget is not None and (not math.isfinite(data.soft_budget) or data.soft_budget < 0):\n        raise HTTPException(\n            status_code=400,\n            detail={\"error\": f\"soft_budget must be a non-negative finite number. Received: {data.soft_budget}\"},\n        )","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/organization_endpoints.py#L378-L414","documentation":"Authorization guard in the organization creation endpoint (/organization/new). LiteLLM reserves org creation for PROXY_ADMIN users; the request's key/user metadata resolved to a role that is missing or not admin, so the endpoint rejects it with 401 before touching the DB. This is expected for self-serve or internal users attempting to create organizations; an admin key must be used, or the user's role must be elevated.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/organization_endpoints.py:396 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a PROXY_ADMIN API key to create organizations."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}