Connect FlutterFlow to DeepAI using a FlutterFlow API Call pointed at a Firebase Cloud Function proxy that adds the DeepAI api-key header. Never place the api-key in client Dart or App Constants — it would ship in your APK or web bundle. The proxy forwards requests to api.deepai.org endpoints like text2img, sentiment-analysis, and summarization, returning an output_url you can load directly into an Image widget.
| Fact | Value |
|---|---|
| Tool | DeepAI |
| Category | AI & ML |
| Method | FlutterFlow API Call |
| Difficulty | Intermediate |
| Time required | 45 minutes |
| Last updated | July 2026 |
Adding AI Image Generation and Text Analysis to Your FlutterFlow App with DeepAI
DeepAI differs from GPT-style APIs in that each capability is its own focused endpoint under https://api.deepai.org/api/{name}. You pick the endpoint that matches your use case — text2img for image generation, summarization for text summaries, sentiment-analysis for opinion mining — and POST a simple text or image field. The response JSON contains an output_url for image results or a plain result string for text results. This single-endpoint simplicity makes DeepAI approachable for non-technical founders.
The catch is authentication. DeepAI uses a custom api-key header rather than the standard Authorization: Bearer pattern most people expect. More importantly, that api-key is a secret credential: placing it in a FlutterFlow API Call header ships it inside every compiled APK and web bundle, where it can be trivially extracted from the binary. The correct architecture routes your FlutterFlow API Call to a Firebase Cloud Function you control; the function adds the api-key header server-side and forwards to api.deepai.org.
DeepAI offers a free tier for experimentation and a pay-as-you-go model for higher volumes — check the current limits on deepai.org/pricing, because rate limits and free quotas change. The integration you will build here works on all platforms: iOS, Android, and web. Web builds that bypass the proxy will see a CORS error from the browser; the proxy resolves that too.
Integration method
FlutterFlow sends requests to a Firebase Cloud Function proxy you deploy. The proxy appends the secret DeepAI api-key header and forwards the request to the appropriate api.deepai.org endpoint. Results — including an output_url for image endpoints — are returned as JSON, parsed with a JSON Path in FlutterFlow, and bound to widgets.
Prerequisites
- A DeepAI account with an api-key (sign up at deepai.org — free tier available)
- A Firebase project with Cloud Functions enabled (Blaze pay-as-you-go plan required for outbound HTTP calls)
- Node.js knowledge is helpful for writing the Cloud Function, though the snippet below is copy-paste ready
- A FlutterFlow project on a paid plan (API Calls and Custom Code are available on paid tiers)
- Basic familiarity with FlutterFlow's API Calls panel and App State variables
Step-by-step guide
Deploy a Firebase Cloud Function proxy that adds the DeepAI api-key header
The most important step comes first: before you touch FlutterFlow, you need a server that securely holds your DeepAI api-key and forwards requests. FlutterFlow compiles to a client app (iOS, Android, or web), which means any key you place in an API Call header ends up inside the app binary where it can be extracted. A Firebase Cloud Function runs on Google's servers, never on the device, so your api-key stays safe. In your Firebase project, navigate to the Cloud Functions section and create a new function (or use an existing one). The function accepts a POST request from FlutterFlow, reads the endpoint name and form data from the request body, adds the DeepAI api-key header server-side, and forwards the request to api.deepai.org. It then returns the DeepAI JSON response to FlutterFlow. Important notes: Firebase Cloud Functions require the Blaze (pay-as-you-go) plan before they can make outbound HTTP calls to external APIs. Set your api-key as an environment variable in Cloud Functions (using firebase functions:config:set or the Secret Manager) rather than hardcoding it in the function source. Deploy the function and copy the HTTPS trigger URL — you will use it as the base URL in FlutterFlow.
1// functions/index.js2const functions = require('firebase-functions');3const axios = require('axios');4const FormData = require('form-data');56exports.deepaiProxy = functions.https.onRequest(async (req, res) => {7 // Allow CORS for web builds8 res.set('Access-Control-Allow-Origin', '*');9 res.set('Access-Control-Allow-Methods', 'POST, OPTIONS');10 res.set('Access-Control-Allow-Headers', 'Content-Type');11 if (req.method === 'OPTIONS') { res.status(204).send(''); return; }1213 const endpoint = req.body.endpoint || 'text2img';14 const inputText = req.body.text || '';1516 const apiKey = functions.config().deepai.key; // set via firebase functions:config:set deepai.key="YOUR_KEY"1718 const form = new FormData();19 form.append('text', inputText);2021 try {22 const response = await axios.post(23 `https://api.deepai.org/api/${endpoint}`,24 form,25 {26 headers: {27 ...form.getHeaders(),28 'api-key': apiKey,29 },30 }31 );32 res.json(response.data);33 } catch (err) {34 res.status(500).json({ error: err.message });35 }36});Pro tip: Install axios and form-data in your functions directory: navigate to the functions/ folder in Firebase CLI and run npm install axios form-data. FlutterFlow handles its own packages — this install is for your Cloud Function only.
Expected result: A deployed Cloud Function with an HTTPS trigger URL like https://us-central1-YOUR-PROJECT.cloudfunctions.net/deepaiProxy. Posting {"endpoint":"text2img","text":"a sunset over the ocean"} to that URL returns a DeepAI JSON response with an output_url field.
Create a FlutterFlow API Group pointing at your Cloud Function proxy
Now open FlutterFlow and click API Calls in the left navigation panel. Click the + Add button at the top of the panel and choose Create API Group. Give the group a name like DeepAI Proxy and set the Base URL to your Cloud Function's HTTPS trigger URL from the previous step — for example https://us-central1-YOUR-PROJECT.cloudfunctions.net/deepaiProxy. You do not need to add any authentication headers to this API Group because the api-key is handled server-side in your Cloud Function. The FlutterFlow client just calls your proxy endpoint; the proxy takes care of credentialing with DeepAI. Once the group is created, click + Add inside the group to create an API Call. Name it something like GenerateImage or AnalyzeSentiment depending on your first use case. Set the method to POST. For the endpoint path, you can leave it empty (the Cloud Function URL is the full endpoint) or set it to a path segment if you have a routing scheme in your function. Navigate to the Body tab of the API Call and set the body type to JSON (not form-data — you are sending JSON to your Cloud Function, which internally builds the multipart form for DeepAI). In the body, add a JSON template: { "endpoint": "text2img", "text": "{{ promptText }}" } Then click the Variables tab and add a variable called promptText (type String). FlutterFlow will replace {{ promptText }} at runtime with whatever text the user provides.
1// API Call Body (JSON template in FlutterFlow Body tab)2{3 "endpoint": "text2img",4 "text": "{{ promptText }}"5}Pro tip: If you plan to support multiple DeepAI endpoints (text2img, sentiment-analysis, summarization), add an endpoint variable too and set it dynamically from your UI so you can reuse the same API Call for different capabilities.
Expected result: A DeepAI Proxy API Group appears in your API Calls panel with one API Call inside it. The call shows POST method, a JSON body template with a promptText variable, and no hardcoded api-key headers.
Test the API Call and set up JSON Path parsing for the response
With the API Call configured, click the Response & Test tab inside the call. You will see a test panel where you can fill in the variable values and fire a test request. Enter a sample prompt text — for example a red sports car on a mountain road — and click Send Test Request. If your Cloud Function is deployed and your api-key is correctly configured, you should receive a JSON response from DeepAI within a few seconds. For the text2img endpoint, the response looks like: { "id": "abc123...", "output_url": "https://api.deepai.org/job-view-file/abc123.../outputs/output.jpg" } Click Generate JSON Paths from Response in FlutterFlow. It will analyze the response structure and automatically create JSON path entries. Find or create the JSON path for output_url: the path is $.output_url. Give it a name like imageUrl and set the type to String. For text-based endpoints like summarization, the result field is typically at $.output. Name that path resultText and type it as String. If your test returns a 401 error, the api-key is missing or wrong in your Cloud Function configuration. Double-check your firebase functions:config:set command and redeploy. If you see a 5xx error, check your Cloud Function logs in the Firebase Console for the specific error message — the most common cause is a missing npm package (form-data or axios not installed in functions/).
Pro tip: The output_url that DeepAI returns for image endpoints is a direct CDN link — you can set it as the Image Path in a FlutterFlow Image widget without any additional processing. The link is publicly accessible for a limited time, so download and store the image in Firebase Storage if you need it permanently.
Expected result: The Response & Test panel shows a successful 200 response with the DeepAI JSON body. FlutterFlow has generated JSON paths including $.output_url (named imageUrl, type String) that you can reference in widget bindings.
Build the UI and bind the API Call result to widgets
With a working, tested API Call, you can now wire it into your FlutterFlow UI. For an image generation use case, add a Column to your page containing a TextField (for the prompt), a Button labeled Generate, and an Image widget below. Create an App State variable called generatedImageUrl (type String, default empty string) and another called isLoading (type Boolean, default false). On the Image widget, set its Image Path to the App State variable generatedImageUrl. Add a conditional visibility so the Image widget only shows when generatedImageUrl is not empty. Now set up the button's Action Flow. Open the Actions panel for the Generate button and click + Add Action. Search for Update App State and set isLoading to true. Add a second action of type Backend/API Call, select your DeepAI Proxy API Group and the GenerateImage call, and map the promptText variable to the TextField's value. In the On Success branch, add Update App State actions to set generatedImageUrl to the imageUrl JSON path result from the API response, then set isLoading back to false. In the On Error branch, show a Snack Bar with an error message and reset isLoading. If you want a loading indicator, add a CircularProgressIndicator widget to the page and make it visible only when isLoading is true, hidden otherwise. This gives users visual feedback while the DeepAI generation runs (typically 2-8 seconds for image endpoints). For sentiment analysis, the UI pattern is similar but simpler: instead of an Image widget, add a Text widget bound to a resultText App State variable and color it conditionally (green for positive sentiment score, red for negative).
Pro tip: DeepAI image generation can take up to 10 seconds for complex prompts. Always set a loading state and never make the user wonder if the app has frozen. A simple CircularProgressIndicator with conditional visibility keeps the experience smooth.
Expected result: The Generate button triggers the API call, a loading spinner appears during processing, and the returned image URL populates the Image widget on success. The complete flow works without any api-key visible in the FlutterFlow canvas or Dart code.
Handle errors and add CORS support for web builds
Before publishing your app, test specifically on the target platforms. Mobile builds (iOS and Android) will not encounter CORS issues because the native HTTP client bypasses the browser's cross-origin restrictions. However, if you publish to web (FlutterFlow's web build or a Vercel/Firebase Hosting deployment), browsers enforce CORS: a direct call to api.deepai.org would fail with a No 'Access-Control-Allow-Origin' header error. Your Cloud Function proxy solves this because you control the CORS headers on your own Firebase endpoint. The index.js snippet in Step 1 already includes the CORS headers (Access-Control-Allow-Origin: *). Verify they are present in your deployed function by opening your browser's developer tools, going to the Network tab, and running a test request. You should see the CORS headers in the response. If you see the XMLHttpRequest error in FlutterFlow's web Test Mode, it almost always means you are calling DeepAI directly rather than through the proxy — double-check the Base URL in your API Group. On the error handling side, add logic in your Action Flow for these common scenarios: a 429 response means you have hit DeepAI's rate limit for your plan — show a friendly Please try again in a moment message and do not retry automatically. A 401 means the api-key is missing or invalid in your Cloud Function configuration. A 500 from your proxy means an unexpected error occurred server-side — log it in the Firebase Console and check your Cloud Function logs for details. Adding these error branches to your Action Flow gives your app a production-quality feel.
Pro tip: Use FlutterFlow's Test Mode (not Run Mode) to quickly verify API Call responses. Run Mode requires a web or device build and is slower to iterate on during development.
Expected result: The app runs correctly on both mobile (iOS/Android) and web. CORS headers appear in the proxy response. Error conditions (rate limit, invalid key) show user-friendly messages rather than blank screens or unhandled exceptions.
Secure and optimize the integration before launch
With the core integration working, there are a few final hardening steps before you publish. First, confirm that your api-key is stored as an environment variable in Cloud Functions (via firebase functions:config:set or the Google Cloud Secret Manager) and not hardcoded in the function source code. If you hardcode it and accidentally push to a public GitHub repository, the key will be exposed. Second, consider adding authentication to your Cloud Function proxy so that only your app's authenticated users can call it. If you are using Firebase Auth in your FlutterFlow app, you can pass the Firebase ID token as a header from FlutterFlow and verify it in the Cloud Function using the Firebase Admin SDK — this prevents random internet users from discovering your proxy URL and abusing your DeepAI credits. Third, think about rate limiting at the proxy level. DeepAI charges per API call (check current pricing at deepai.org/pricing). If your app goes viral or a user accidentally hammers the generate button, you want a server-side guard. A simple counter in Firestore keyed by user ID can prevent per-user abuse without extra infrastructure. Finally, if you want the RapidDev team to handle the Cloud Function setup, CORS configuration, and FlutterFlow wiring for you — particularly for streaming or more complex multi-endpoint patterns — RapidDev builds FlutterFlow integrations like this every week. Book a free scoping call at rapidevelopers.com/contact.
Pro tip: Store the DeepAI api-key in Google Cloud Secret Manager and access it in your Cloud Function via `const {SecretManagerServiceClient} = require('@google-cloud/secret-manager')`. This is more secure than firebase functions:config and is the recommended approach for production secrets.
Expected result: Your DeepAI integration is secure (no api-key in client code), protected by optional Firebase Auth token verification on the proxy, and rate-limited at the server level. The app is ready to publish to the App Store, Play Store, or as a web app.
Common use cases
AI image generation screen inside a creative app
A user types a text prompt into a TextField widget and taps a button. FlutterFlow calls the proxy, which sends the text to DeepAI's text2img endpoint. The returned output_url is loaded into a full-screen Image widget, and the user can save or share the result. The entire experience stays inside the app with no external browser required.
Build a screen with a text input for a creative prompt, a Generate button that calls DeepAI text2img through a proxy, and a large image area that shows the returned output_url once generation completes.
Copy this prompt to try it in FlutterFlow
Customer review sentiment dashboard for an e-commerce app
A founder building a seller dashboard wants to classify customer reviews as positive, negative, or neutral without training a custom model. Each review text is sent to the DeepAI sentiment-analysis endpoint via the proxy. The JSON score is parsed and displayed as a color-coded badge next to each review in a ListView.
Create a reviews list page that sends each review text to a DeepAI sentiment-analysis proxy endpoint and shows a color-coded badge (green/red/grey) based on the returned sentiment score.
Copy this prompt to try it in FlutterFlow
Article summarizer for a content-reading app
Users paste long article text into the app and tap Summarize. FlutterFlow sends the text to the DeepAI summarization endpoint through the proxy. The returned condensed summary is displayed in a separate Card widget below the original text, giving users a quick TL;DR without leaving the app.
Add a Summarize button to the article detail screen. On tap, send the article body text to a DeepAI summarization proxy and display the result summary in a card below the full content.
Copy this prompt to try it in FlutterFlow
Troubleshooting
API call returns 401 Unauthorized from DeepAI
Cause: The api-key is missing, misspelled, or not being passed correctly by the Cloud Function. This also happens if you accidentally used Authorization: Bearer format instead of the api-key header name that DeepAI requires.
Solution: Open your Firebase Console, navigate to Cloud Functions, and check the function logs. Verify that the api-key value is being read correctly (not undefined). Confirm the header name in your axios request is exactly 'api-key' with a lowercase hyphen — DeepAI does not accept 'Authorization: Bearer'. Re-run firebase functions:config:set deepai.key="YOUR_ACTUAL_KEY" and redeploy the function.
XMLHttpRequest error in FlutterFlow web preview or published web app
Cause: The FlutterFlow API Call is pointing directly to api.deepai.org instead of your Cloud Function proxy. Browsers enforce CORS and block cross-origin requests to DeepAI's servers from a web origin.
Solution: Open the API Group in FlutterFlow's API Calls panel and verify the Base URL is your Cloud Function HTTPS trigger URL, not https://api.deepai.org. Ensure your Cloud Function includes Access-Control-Allow-Origin: * and handles OPTIONS preflight requests. Redeploy and test again in FlutterFlow Test Mode.
The output_url Image widget shows a broken image or nothing after a successful API call
Cause: The JSON path for output_url is incorrect, the output_url field is missing in the response (some endpoints return a result field instead), or the image URL has already expired (DeepAI CDN links are temporary).
Solution: Go to the Response & Test tab in FlutterFlow and examine the raw response JSON. Confirm that output_url exists in the response structure. Copy the exact path — for text2img it is $.output_url, but some other endpoints use $.output. If the image link expired, re-trigger the generation and immediately load the new URL. For permanent storage, download and save the image to Firebase Storage using a Cloud Function right after generation.
API call returns 429 Too Many Requests
Cause: You have exceeded DeepAI's rate limit for your current plan. Free tier accounts have strict per-minute and daily limits that are easy to hit during development.
Solution: Check your current usage in the DeepAI dashboard at deepai.org. Add a brief delay between calls during testing. In production, add a server-side counter in Firestore to throttle per-user call frequency. Consider upgrading to a paid DeepAI plan if your app has regular active users.
Best practices
- Never put the DeepAI api-key in a FlutterFlow API Call header, App Constants, or Dart code — it ships in the compiled app binary and can be extracted from any APK or web bundle
- Route all DeepAI calls through a Firebase Cloud Function or Supabase Edge Function proxy; add Firebase Auth token verification to the proxy to prevent unauthorized usage
- Use the correct header format for DeepAI: the header name is api-key (lowercase with hyphen), not Authorization: Bearer — this mismatch causes silent 401 errors
- For image endpoints, output_url links are temporary CDN links — if you need to display or reference them later, download the image to Firebase Storage immediately after generation
- Match the body type to what your Cloud Function expects: send JSON from FlutterFlow to your proxy, and let the proxy build the multipart/form-data that DeepAI requires
- Add a loading indicator (CircularProgressIndicator with conditional visibility) for image generation calls, which can take 2-10 seconds — never leave users staring at a static screen
- Handle 429 rate-limit responses with a friendly user message and a brief cooldown rather than an automatic retry loop that could rapidly burn through your quota
- Test your integration in FlutterFlow Test Mode first (fast iteration), then verify on a real device or APK before submitting to the App Store or Play Store
Alternatives
Choose OpenAI if you need a conversational chat interface, complex multi-turn prompts, or higher-quality image generation via DALL-E — DeepAI's single-purpose endpoints are simpler but less capable for open-ended generation tasks.
Choose Vertex AI if you want to deploy and serve your own trained models or need enterprise-grade ML infrastructure with Google service-account auth — DeepAI is simpler but covers only its pre-built endpoint catalog.
Choose IBM Watson if you need enterprise NLU, speech-to-text, or a multi-service suite with regional data-residency options — DeepAI focuses on image and text generation with a simpler pay-as-you-go pricing model.
Frequently asked questions
Can I call DeepAI directly from a FlutterFlow API Call without a Cloud Function?
Technically yes on mobile — iOS and Android builds do not enforce CORS, so the call will succeed. However, doing so puts your api-key in the compiled APK or IPA where it can be extracted with standard reverse-engineering tools. Anyone who finds your key can use your DeepAI quota and run up charges. Always route through a Cloud Function proxy so the key stays server-side.
Why does DeepAI use api-key as a header instead of Authorization: Bearer?
DeepAI chose a custom header name rather than the OAuth Bearer standard. This is just their API design. If you configure your Cloud Function proxy or FlutterFlow API Call with Authorization: Bearer YOUR_KEY, DeepAI will return a 401 Unauthorized — it only recognizes the api-key header. Always double-check the exact header format in the API documentation of whichever endpoint you are using.
Does DeepAI work in FlutterFlow's web build?
Yes, through the Cloud Function proxy. If you route calls through your own Firebase endpoint (which includes the Access-Control-Allow-Origin header), web builds work fine. Direct calls from a browser to api.deepai.org will be blocked by CORS. FlutterFlow's Test Mode routes through FlutterFlow's own proxy so calls may appear to work there even without CORS headers — always test your published web build to confirm the real behavior.
How do I use multipart form-data for image inputs to DeepAI endpoints that accept images?
The multipart form-data handling belongs in your Cloud Function proxy, not in FlutterFlow directly. Pass the image as a base64-encoded string in your JSON request from FlutterFlow, then in the Cloud Function decode it, build a FormData object with the image buffer appended as an image field, and send it to the DeepAI endpoint. This keeps the FlutterFlow API Call simple (JSON body) while the proxy handles the multipart encoding that DeepAI requires.
Can I use DeepAI for real-time features like live image processing?
DeepAI endpoints are synchronous HTTP requests with processing times ranging from 1-10 seconds depending on the model. They are not designed for real-time streaming or live video processing. For real-time AI features in a mobile app, consider on-device models via the tflite_flutter package instead, which process data with zero network latency and no per-call cost.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation