{"record":{"id":"e299357634ad849d","repo":"odysseus-dev/odysseus","slug":"api-token-is-not-scoped-for-chat","errorCode":null,"errorMessage":"API token is not scoped for chat","messagePattern":"API token is not scoped for chat","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"routes/model_routes.py","lineNumber":1628,"sourceCode":"                    \"category\": category,\n                    \"endpoint_kind\": kind,\n                    \"model_type\": ep_model_type,\n                    \"offline\": True,\n                })\n\n        return {\"hosts\": [], \"items\": items}\n\n    @router.get(\"/models\")\n    def api_models(request: Request, refresh: bool = False, background: bool = False):\n        \"\"\"Get available models — per-user (caller sees only their endpoints +\n        legacy/shared null-owner rows). Cached per-user for 30s.\"\"\"\n        # Require auth; \"\" is the unconfigured single-user mode, treated as\n        # \"see everything\" by _fetch_models.\n        try:\n            if getattr(request.state, \"api_token\", False):\n                scopes = set(getattr(request.state, \"api_token_scopes\", []) or [])\n                if \"chat\" not in scopes:\n                    raise HTTPException(403, \"API token is not scoped for chat\")\n                if not getattr(request.state, \"api_token_owner\", None):\n                    raise HTTPException(403, \"API token has no owner\")\n            owner = effective_user(request) or \"\"\n\n            # Reject anonymous in configured deployments — no leaking the model\n            # list to unauthenticated callers.\n            auth_mgr = getattr(request.app.state, \"auth_manager\", None)\n            if not owner and not _auth_disabled() and auth_mgr is not None and getattr(auth_mgr, \"is_configured\", False):\n                raise HTTPException(401, \"Not authenticated\")\n        except HTTPException:\n            raise\n        except Exception as e:\n            logger.error(\"Auth gate error in GET /api/models, failing closed: %s\", e)\n            raise HTTPException(status_code=500, detail=\"Internal error\")\n        # Admins see every endpoint (they manage the global pool); regular\n        # users get the owner-scoped view.\n        _is_admin = False\n        try:","sourceCodeStart":1610,"sourceCodeEnd":1646,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/model_routes.py#L1610-L1646","documentation":"Error \"API token is not scoped for chat\" thrown in odysseus-dev/odysseus.","triggerScenarios":"Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.","commonSituations":"See trigger scenarios.","solutions":["Use an API token that includes the chat scope.","Create a new token with chat scope in the token management UI."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}