What kind of backend is best for a mobile app using AI?

Hey,

I’ve been trying to build an app that uses the OpenAI API. Since it is a really bad idea to store the api key in the app, I need some form of backend. I’d be curious what other people have chosen to do here. What kind of backend did you use or build to support your mobile app?

Build my own backend with Swift

I am a professional iOS developer, I know Swift programming very well and there is a Swift backend project (Swift Vapor) that I can use to build my own backend. I have used it before, but deploying a Swift backend is really tricky when you have no idea what you are doing. It’s easy to get a first deployment ready, but setting up everything around it (logging, monitoring, rate limiting etc.) is extremely hard. I’ve once tried for several weeks and did not make any progress. There’s also barely any documentation around it.

To add on top of that: There are basically no SDKs that properly work in a Swift backend (because it’s running on Linux). So I’d have to build a lot of things on my own, including the entire REST API for services like OpenAI.

Build my own backend with JavaScript

There are tons of frameworks, SDKs and tutorials out there to build a JS/TS backend with. The problem is that I despise JS/TS with all my heart. I’ve built a TS backend before and I hated every single part of it :sweat_smile:. It was miserable and I lost all motivation and fun (no offence to anyone loving JS/TS, it’s just not for me, really).

So this might be a simpler solution but it would threaten me to eventually flip and give up programming in its entirety and never touch a computer again. Which is not great.

Build my own backend with Python

I always see tons of examples online that use Python for their OpenAI api calls. Is Python a viable backend solution? And what would be a good place to deploy it easily?


If any of you have built a mobile app with AI in it, what did you do as a backend solution? Are there other, more convenient ways?

Thanks!

1 Like

For a backend, I use AWS Lambda for API calls. You can write in any language, including Swift, but I generally use Python.

They even have a Swift SDK.

https://docs.aws.amazon.com/sdk-for-swift/

2 Likes

Sorry, I didn’t see the answer until now!

Thanks :slight_smile:

I will take a look at this. So far, I’ve been fairly scared of AWS because of its complexity and all those horror stories about people receiving large bills from misconfigured things :sweat_smile: