{"id":1131,"url":"https://forum.supero.dev/t/ai-v1-chat-returns-401-with-an-api-key-that-works-for-crud-1131","title":"`/ai/v1/chat` returns 401 with an API key that works for CRUD","type":"question","status":"solved","category":{"slug":"ai-agent","name":"In-App AI Agent"},"tags":["ai-agent-api","api-keys","jwt"],"author":{"handle":"supero-support","name":"Supero Support","team":true},"created":"2026-12-04T02:41:02.705Z","updated":"2026-12-04T02:41:02.705Z","upvotes":0,"error_text":"Authorization header with Bearer token required","environment":{"client":null,"sdk_version":null,"deploy_target":null},"body_markdown":"The same key works on `/api/v1/crud/...`:\n```bash\ncurl -X POST https://api.supero.dev/ai/v1/chat -H \"X-API-Key: $SUPERO_KEY\" \\\n  -H \"Content-Type: application/json\" -d '{\"message\": \"How many open orders?\"}'\n```\nResponse: 401, \"Authorization header with Bearer token required\".","answers":[{"id":"cd64d72e-ceda-4b14-ae1e-a4975681e547","url":"https://forum.supero.dev/t/ai-v1-chat-returns-401-with-an-api-key-that-works-for-crud-1131#post-cd64d72e-ceda-4b14-ae1e-a4975681e547","author":{"handle":"supero-platform","name":"Supero Platform team","team":true},"accepted":true,"official":false,"outdated":false,"sdk_version":null,"upvotes":0,"created":"2026-12-04T02:41:02.705Z","updated":"2026-12-04T02:41:02.705Z","body_markdown":"The AI Agent API doesn't accept `X-API-Key`. Every `/ai/v1/*` route needs `Authorization: Bearer <jwt>`, the token from `POST /api/v1/auth/login`:\n\n```bash\ncurl -X POST https://api.supero.dev/ai/v1/chat \\\n  -H \"Authorization: Bearer $ACCESS_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"message\": \"How many open orders?\"}'\n```\n\nThe agent has no credential of its own. It runs every tool with the JWT you send, on the same access-controlled paths as your other calls, so it can only read and change what that user already could. Inside a generated app there is nothing to send by hand: the built-in chat runs as the signed-in user and needs no API key.","comments":[]}],"licence":"CC BY-SA 4.0 (code: MIT-0)"}