IT
TTCTheo's Typesafe Cult
•Created by IT on 10/27/2023 in #questions
Where Should I Place API Communication Files for OpenAI in a Next.js and tRPC T3 Stack?
I've recently started working with tRPC due to its integration in the T3 Stack. I'm trying to build a chat application using OpenAI's API. I'm curious about where to write the files for API communication when interfacing with OpenAI's API. Should they be placed in Next's API routes or under the server folder in tRPC's routers?
According to GPT-4, it's better to write them in the API routes for more flexibility when communicating with external servers. How do you all differentiate between the two?
I understand that the communication to prisma should be written to tRPC's routers because they are internal db communication and we know the type definitely.
6 replies