Skip to content
Community forum

/ai/v1/chat returns 401 with an API key that works for CRUD

SolvedSupero SupportSupero team asked

Common question, written up by the Supero team.

Error message
Authorization header with Bearer token required

The same key works on /api/v1/crud/...:

bash
curl -X POST https://api.supero.dev/ai/v1/chat -H "X-API-Key: $SUPERO_KEY" \
  -H "Content-Type: application/json" -d '{"message": "How many open orders?"}'

Response: 401, "Authorization header with Bearer token required".

Link

1 answer

Accepted answer
Accepted answer

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:

bash
curl -X POST https://api.supero.dev/ai/v1/chat \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "How many open orders?"}'

The 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.

Supero Platform teamSupero team answered
Link

Your answer

/ai/v1/chat returns 401 with an API key that works for CRUD | Supero Community