Summary
src/interfaces/chat_app/api.py defines a Flask Blueprint with 20+ routes under /api, but register_api(app) is never called from app.py. All routes in this blueprint are unreachable at runtime.
This includes the token management endpoints needed for the OpenAI-compatible /v1 API:
POST /api/users/me/api-token — generate a bearer token
GET /api/users/me/api-token — check if user has a token
DELETE /api/users/me/api-token — revoke a token
Without these endpoints, there is no way for users to obtain an archi_ API token for authenticated access to /v1/chat/completions.
Root Cause
The codebase uses two Flask routing patterns:
- Legacy —
self.add_endpoint() calls in FlaskAppWrapper.__init__ (~50 routes in app.py)
- Blueprint —
register_blueprint() used by openai_compat.py and service_alerts.py
api.py follows the blueprint pattern and defines register_api(app) at line 1157, but no code in app.py (or anywhere else) calls it.
Route Conflicts
Registering the full blueprint will cause 3 conflicts with existing add_endpoint() routes (same path + method):
| Route |
app.py (legacy) |
api.py (blueprint) |
Notes |
GET /api/health |
Always returns {"status": "OK"} — no real check |
Tests DB connectivity, returns 503 on failure |
Blueprint version is better |
GET /api/agents/template |
Richer tool data (name + description), has auth |
Flat tool list, no auth decorator |
Legacy version is better |
POST /api/agents |
Create + edit modes, auto-filenames, rename tracking, session auth |
Create only, manual filenames, weaker auth |
Legacy version is better |
These must be resolved before wiring up the blueprint.
Suggested Fix
- Remove the 2 inferior duplicate routes from
api.py (agents/template GET, agents POST) and their 5 now-dead helper functions (_get_agents_dir_from_config, _get_agent_class_name_from_config, _get_agent_tool_registry, _build_agent_template, _sanitize_filename)
- Remove the health stub from
app.py's add_endpoint calls (let the blueprint's real DB health check replace it)
- Add
register_api(self.app) in app.py next to the other blueprint registrations
- Clean up dead imports (
os, Path, AgentSpecError, load_agent_spec)
Pyright Type Errors in api.py
The blueprint also has pre-existing type issues that should be fixed:
User model missing attributes: api_key_openrouter, api_key_openai, api_key_anthropic
display_name not a valid parameter in a constructor call
None passed where str expected (set_api_key, fromisoformat)
int passed where str | None expected (get_enabled_document_ids)
Impact
- Users cannot generate API tokens for authenticated
/v1 access
- The real health check endpoint (with DB connectivity test) is unreachable
- Config, analytics, document selection, and prompt management routes in the blueprint are all dead code
Summary
src/interfaces/chat_app/api.pydefines a Flask Blueprint with 20+ routes under/api, butregister_api(app)is never called fromapp.py. All routes in this blueprint are unreachable at runtime.This includes the token management endpoints needed for the OpenAI-compatible
/v1API:POST /api/users/me/api-token— generate a bearer tokenGET /api/users/me/api-token— check if user has a tokenDELETE /api/users/me/api-token— revoke a tokenWithout these endpoints, there is no way for users to obtain an
archi_API token for authenticated access to/v1/chat/completions.Root Cause
The codebase uses two Flask routing patterns:
self.add_endpoint()calls inFlaskAppWrapper.__init__(~50 routes inapp.py)register_blueprint()used byopenai_compat.pyandservice_alerts.pyapi.pyfollows the blueprint pattern and definesregister_api(app)at line 1157, but no code inapp.py(or anywhere else) calls it.Route Conflicts
Registering the full blueprint will cause 3 conflicts with existing
add_endpoint()routes (same path + method):app.py(legacy)api.py(blueprint)GET /api/health{"status": "OK"}— no real checkGET /api/agents/templatePOST /api/agentsThese must be resolved before wiring up the blueprint.
Suggested Fix
api.py(agents/templateGET,agentsPOST) and their 5 now-dead helper functions (_get_agents_dir_from_config,_get_agent_class_name_from_config,_get_agent_tool_registry,_build_agent_template,_sanitize_filename)app.py'sadd_endpointcalls (let the blueprint's real DB health check replace it)register_api(self.app)inapp.pynext to the other blueprint registrationsos,Path,AgentSpecError,load_agent_spec)Pyright Type Errors in
api.pyThe blueprint also has pre-existing type issues that should be fixed:
Usermodel missing attributes:api_key_openrouter,api_key_openai,api_key_anthropicdisplay_namenot a valid parameter in a constructor callNonepassed wherestrexpected (set_api_key,fromisoformat)intpassed wherestr | Noneexpected (get_enabled_document_ids)Impact
/v1access