Set up your AI Proxy Backend.
The AI Proxy Backend is a NodeJS backend that will proxy requests to AI services.
So your API keys are not exposed to the users. They are safe in the backend.
Firebase Service Account JSON file.
You can not send requests to the backend without Firebase Token Verification. This is a security feature.
/auth
POST
endpoint for authentication and get secret key./ai/openai
POST
endpoint for OpenAI requests/ai/openai/stream
POST
endpoint for OpenAI streaming requests/ai/vision
POST
endpoint for OpenAI Vision API requests/ai/anthropic
POST
endpoint for Anthropic requests/ai/anthropic/stream
POST
endpoint for Anthropic streaming requests/ai/replicate/generate
POST
endpoint for Replicate requests/ai/fal/generate
POST
endpoint for Fal AI requestsOur backend uses a multi-layer security approach:
useHmac
hook and api-client.ts
in the Expo code for implementationpnpm run dev
http://localhost:3000/...
But if you try to send requests with your local device, you can’t do that.
I believe the easiest way to test your backend is using the ngrok.
You can check: ngrok but be careful. It is opening a tunnel to your local machine.
Otherwise you can find your local ip address and send requests to it.
https://[your-ngrok-id].ngrok.app/...
Now you need to clone the AI Proxy Backend (NodeJS) Repository.
Make sure you are not in the your-project-name
folder.
Open your terminal and run the commend above.
Then type cd [your-project-name]-backend
.
After cloning the project, create two environment files:
Install the dependencies. I am using pnpm
but you can use npm
or yarn
.
Then you need to run the generate-keys
command to create the security keys.
You need to add to the .env.production
file too.
As you can see, the API_KEY
and HMAC_SECRET_KEY
are created.
Now type your app identifier: like: com.shipmobilefast.app
.
And copy the API_KEY
and paste it on the Expo project’s .env
file.
ALLOWED_ORIGINS
is the list of origins that are allowed to send requests to the backend.
So make it your app’s identifier.Get your AI Provider Keys.
Add your AI API keys to the .env.local
and .env.production
files.
You don’t have to use all of them in the backend. You can use only the ones you need.
Now we need to download the Firebase Service Account JSON file.
This file is very important. Do not share it with anyone.
Go to the Project Settings and click on the Service Accounts
tab.
Click on the Generate New Private Key
button.
Click on the Generate Key
button.
After downloading the JSON file, you need to add it to the backend and change the name as firebase-service-account.json
.
Make sure you add the file to the .gitignore
file and never commit it to the repository.
Never add this on Expo project.
Now you can start the backend.
Don’t forget to add API_KEY to the Expo project’s .env
file.
Create a development build
Set up your AI Proxy Backend.
The AI Proxy Backend is a NodeJS backend that will proxy requests to AI services.
So your API keys are not exposed to the users. They are safe in the backend.
Firebase Service Account JSON file.
You can not send requests to the backend without Firebase Token Verification. This is a security feature.
/auth
POST
endpoint for authentication and get secret key./ai/openai
POST
endpoint for OpenAI requests/ai/openai/stream
POST
endpoint for OpenAI streaming requests/ai/vision
POST
endpoint for OpenAI Vision API requests/ai/anthropic
POST
endpoint for Anthropic requests/ai/anthropic/stream
POST
endpoint for Anthropic streaming requests/ai/replicate/generate
POST
endpoint for Replicate requests/ai/fal/generate
POST
endpoint for Fal AI requestsOur backend uses a multi-layer security approach:
useHmac
hook and api-client.ts
in the Expo code for implementationpnpm run dev
http://localhost:3000/...
But if you try to send requests with your local device, you can’t do that.
I believe the easiest way to test your backend is using the ngrok.
You can check: ngrok but be careful. It is opening a tunnel to your local machine.
Otherwise you can find your local ip address and send requests to it.
https://[your-ngrok-id].ngrok.app/...
Now you need to clone the AI Proxy Backend (NodeJS) Repository.
Make sure you are not in the your-project-name
folder.
Open your terminal and run the commend above.
Then type cd [your-project-name]-backend
.
After cloning the project, create two environment files:
Install the dependencies. I am using pnpm
but you can use npm
or yarn
.
Then you need to run the generate-keys
command to create the security keys.
You need to add to the .env.production
file too.
As you can see, the API_KEY
and HMAC_SECRET_KEY
are created.
Now type your app identifier: like: com.shipmobilefast.app
.
And copy the API_KEY
and paste it on the Expo project’s .env
file.
ALLOWED_ORIGINS
is the list of origins that are allowed to send requests to the backend.
So make it your app’s identifier.Get your AI Provider Keys.
Add your AI API keys to the .env.local
and .env.production
files.
You don’t have to use all of them in the backend. You can use only the ones you need.
Now we need to download the Firebase Service Account JSON file.
This file is very important. Do not share it with anyone.
Go to the Project Settings and click on the Service Accounts
tab.
Click on the Generate New Private Key
button.
Click on the Generate Key
button.
After downloading the JSON file, you need to add it to the backend and change the name as firebase-service-account.json
.
Make sure you add the file to the .gitignore
file and never commit it to the repository.
Never add this on Expo project.
Now you can start the backend.
Don’t forget to add API_KEY to the Expo project’s .env
file.
Create a development build