In dev mode (npm run dev) works fine but in production (npm run start) I get "o.index is not a function"

Hey there, I am trying to build a cool “Chat2Files” app, which works fairly well in development mode, but when trying to to build it (npm run build) and starting it(npm run start) I get this strange error:

⨯ TypeError: o.index is not a function
    at u (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\.next\server\app\api\chat\route.js:1:1285)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async b (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\.next\server\app\api\chat\route.js:1:2011)     
    at async C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\node_modules\next\dist\compiled\next-server\app-route.runtime.prod.js:6:36258
    at async eR.execute (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\node_modules\next\dist\compiled\next-server\app-route.runtime.prod.js:6:26874)
    at async eR.handle (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\node_modules\next\dist\compiled\next-server\app-route.runtime.prod.js:6:37512)
    at async doRender (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\node_modules\next\dist\server\base-server.js:1377:42)
    at async cacheEntry.responseCache.get.routeKind (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\node_modules\next\dist\server\base-server.js:1599:28)
    at async NextNodeServer.renderToResponseWithComponentsImpl (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\node_modules\next\dist\server\base-server.js:1507:28)
    at async NextNodeServer.renderPageComponent (C:\Users\Heiner\Desktop\next-clerk-shadcn-starter\node_modules\next\dist\server\base-server.js:1931:24)

Somebody knows why that is?
What could cause the issue in production when its running perfectly in dev mode?
I am using latest NextJS and Vercel AI packages.