FlutterFlow's AI chat generates FlutterFlow widgets, actions, and code for you as the app builder — it does not add AI capabilities to your app's end users. To give users AI-powered features, connect a Cloud Function to OpenAI, Claude, or Gemini APIs. FlutterFlow's AI can also write those Cloud Function calls for you, but the underlying AI service must be external.
Clearing up the confusion: builder AI vs. user-facing AI
FlutterFlow has an AI chat panel that many users mistake for a way to add AI features to their app. This is a common misconception. FlutterFlow's AI is a builder tool — it reads your project context (pages, data types, variables) and writes FlutterFlow-compatible code for you as the developer. It's like having an AI pair programmer. It can generate a Custom Action that calls OpenAI, but it does not itself provide OpenAI access to your app users. For your app users to interact with AI (chatbots, text generation, image analysis, recommendations), you must connect your app to external AI APIs — OpenAI, Anthropic Claude, Google Gemini, or similar services — via Cloud Functions or the FlutterFlow API Manager.
Prerequisites
- FlutterFlow account (any plan — AI chat is available on all plans)
- Basic understanding of FlutterFlow pages and widgets
- For adding user-facing AI: Firebase Cloud Functions or Supabase Edge Functions
- API key from OpenAI, Anthropic, or Google AI Studio for user-facing AI features
Step-by-step guide
Understand what FlutterFlow's AI chat can and cannot do
Understand what FlutterFlow's AI chat can and cannot do
Open any FlutterFlow project and look for the AI icon in the left toolbar — it looks like a sparkle or star symbol. Clicking it opens the AI panel where you can type requests in natural language. FlutterFlow's AI can generate: Custom Actions (Dart code), Custom Widgets, Firestore query structures, page layouts, theme configurations, and App State management code. It reads your current project context to generate relevant code. It cannot: give your app users a chatbot, generate text or images for end users, analyze user-submitted photos, or provide any AI service that runs at user request time. The AI generates code for you; the code runs on the user's device but doesn't connect to any AI service unless you write that connection yourself.
Expected result: You understand that FlutterFlow AI generates app-building code for developers, not AI features for app end users.
Use FlutterFlow AI to generate a Custom Action
Use FlutterFlow AI to generate a Custom Action
Open the AI panel. Type a specific request: 'Write a Custom Action named callOpenAI that accepts a prompt string and sends it to the OpenAI chat completions API. Return the response text as a String. Use my OPENAI_API_KEY App Constant.' FlutterFlow's AI will generate Dart code for this Custom Action with the correct http package imports, JSON encoding, error handling, and return type. Copy the generated code into Custom Code → Custom Actions → Add Action. Review the generated code — AI occasionally makes minor errors with FlutterFlow-specific syntax. Fix any issues before saving.
Expected result: FlutterFlow AI generates a complete Dart Custom Action for calling OpenAI. After reviewing and minor fixes, it compiles in the Custom Code editor.
Ask FlutterFlow AI to generate a page layout
Ask FlutterFlow AI to generate a page layout
Type in the AI panel: 'Create a chat page layout with a ListView of message bubbles at the top, a TextField at the bottom for user input, and a Send button. The ListView should show messages from an App State list variable named chatMessages, where each message has text and isUser fields.' FlutterFlow AI generates the widget tree structure and bindings. Click 'Apply to page' or copy the generated configuration. The AI-generated layout will appear in your widget tree. Adjust colors and padding using the properties panel to match your theme.
Expected result: A functional chat page layout is added to your project with the ListView bound to chatMessages and the TextField wired to the send action.
Connect a real OpenAI API for user-facing chat features
Connect a real OpenAI API for user-facing chat features
To give your app users an actual AI chatbot, you need an external API connection. Create a Supabase Edge Function or Firebase Cloud Function named 'chatWithAI'. The function accepts the user's message, calls OpenAI's chat completions API with your API key (stored as a server-side secret), and returns the AI's response. In FlutterFlow, use the API Manager or a Custom Action to call this function. Add the chat response to the chatMessages App State list. This is the full-stack pattern: FlutterFlow UI → your Cloud Function → OpenAI API.
1// Supabase Edge Function: chat-with-ai2// Store OPENAI_API_KEY in Supabase Project Settings → Secrets3import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';45serve(async (req) => {6 const { message, conversationHistory } = await req.json();78 const messages = [9 { role: 'system', content: 'You are a helpful assistant.' },10 ...(conversationHistory || []),11 { role: 'user', content: message },12 ];1314 const response = await fetch('https://api.openai.com/v1/chat/completions', {15 method: 'POST',16 headers: {17 'Authorization': `Bearer ${Deno.env.get('OPENAI_API_KEY')}`,18 'Content-Type': 'application/json',19 },20 body: JSON.stringify({21 model: 'gpt-4o-mini',22 messages,23 max_tokens: 500,24 temperature: 0.7,25 }),26 });2728 const data = await response.json();29 const reply = data.choices?.[0]?.message?.content ?? 'Sorry, I could not respond.';3031 return new Response(JSON.stringify({ reply }), {32 headers: { 'Content-Type': 'application/json' },33 });34});Expected result: Sending a message from the app calls your Edge Function, which returns an AI-generated reply. The reply appears in the chat ListView within 2-3 seconds.
Use FlutterFlow AI to generate the API call Custom Action
Use FlutterFlow AI to generate the API call Custom Action
Return to the FlutterFlow AI panel. Type: 'Write a Custom Action named sendChatMessage that accepts: message (String) and conversationHistory (JSON list). It should POST to my Supabase Edge Function URL with these values, then return the reply string from the JSON response.' FlutterFlow AI will generate the correct Dart code using the http package. It will use your project's Supabase URL from App Constants if you have it set. This demonstrates the correct workflow: use FlutterFlow AI to write the integration code, use your external API service to provide the actual AI capability.
Expected result: FlutterFlow AI generates a working Custom Action and suggests the Action Flow structure. After applying, the chat feature is fully functional end-to-end.
Complete working example
1// FlutterFlow Custom Action: sendChatMessage2// Calls a Supabase Edge Function to get an AI reply3// The Edge Function connects to OpenAI — the API key stays server-side45import 'dart:convert';6import 'package:http/http.dart' as http;78/// Sends a user message to the AI chat Edge Function.9/// Returns the AI's reply as a String.10/// Returns an empty string on error.11Future<String> sendChatMessage(12 String message,13 List<dynamic> conversationHistory,14) async {15 // Set these in FlutterFlow Settings → App Constants16 const String supabaseUrl = 'https://YOUR_PROJECT.supabase.co';17 const String anonKey = 'YOUR_SUPABASE_ANON_KEY';18 const String functionUrl = '$supabaseUrl/functions/v1/chat-with-ai';1920 if (message.trim().isEmpty) return '';2122 // Format history as OpenAI message objects23 final history = conversationHistory.map((item) => {24 'role': item['isUser'] == true ? 'user' : 'assistant',25 'content': item['text'] as String? ?? '',26 }).toList();2728 try {29 final response = await http30 .post(31 Uri.parse(functionUrl),32 headers: {33 'Content-Type': 'application/json',34 'Authorization': 'Bearer $anonKey',35 },36 body: jsonEncode({37 'message': message.trim(),38 'conversationHistory': history,39 }),40 )41 .timeout(const Duration(seconds: 30));4243 if (response.statusCode != 200) {44 debugPrint('AI chat error: ${response.statusCode} ${response.body}');45 return 'Sorry, I encountered an error. Please try again.';46 }4748 final data = jsonDecode(response.body) as Map<String, dynamic>;49 return data['reply'] as String? ?? '';50 } catch (e) {51 debugPrint('sendChatMessage exception: $e');52 return 'Connection error. Please check your network and try again.';53 }54}Common mistakes
Why it's a problem: Expecting FlutterFlow's AI chat to generate AI features for app users
How to avoid: Treat FlutterFlow AI as your coding assistant. It helps you write the Custom Actions and API calls that connect to external AI services. The actual AI responses for users come from OpenAI, Claude, or Gemini — not from FlutterFlow.
Why it's a problem: Calling OpenAI API directly from a Flutter Custom Action with the API key in the code
How to avoid: Always route AI API calls through a server-side function (Supabase Edge Function or Firebase Cloud Function) where the API key is stored as an environment secret. The client calls your function; your function calls OpenAI.
Why it's a problem: Not setting a spending limit on your OpenAI account before giving users AI access
How to avoid: Set a monthly spending limit in your OpenAI account settings before launching. Add per-user rate limiting in your Cloud Function — check how many AI calls the user has made today in a Firestore counter and return an error if they exceed the limit.
Best practices
- Use FlutterFlow AI for generating boilerplate — Custom Action scaffolding, Firestore query structure, widget layouts
- Always route external AI API calls through server-side functions — never embed API keys in client code
- Add per-user rate limiting before launching any user-facing AI feature
- Test AI-generated code carefully — FlutterFlow AI occasionally generates plausible-looking but incorrect FlutterFlow syntax
- Store conversation history in App State (not Firestore) for session-only chats to avoid unnecessary database writes
- Show a streaming typing indicator while waiting for AI responses — improves perceived responsiveness
- Implement graceful error messages when the AI API is unavailable — never show raw API error JSON to users
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm building a FlutterFlow app and want to add a chatbot feature for my users. I have a Supabase project. Can you write a Supabase Edge Function (TypeScript/Deno) that accepts a user message and conversation history, calls the OpenAI gpt-4o-mini chat completions API, and returns the AI reply? The OpenAI API key should be read from a Deno environment variable. Also write the CORS headers so FlutterFlow can call the function from the app.
Using FlutterFlow's built-in AI chat, what is the exact prompt I should type to generate a Custom Action that calls my Supabase Edge Function URL (stored in App Constants as 'supabaseUrl'), sends a message and conversation history as JSON, and returns the AI reply string? I want the action to handle network errors and timeouts gracefully.
Frequently asked questions
What exactly can FlutterFlow's built-in AI generate?
FlutterFlow AI can generate: Custom Actions (Dart code), Custom Widgets, suggested widget trees for page layouts, Firestore query configurations, App State variable structures, and Custom Functions. It understands FlutterFlow's architecture and generates code that fits the platform better than general AI tools like ChatGPT.
Does FlutterFlow AI have access to my project's code and data?
Yes. FlutterFlow AI reads your project context — your pages, data types, collections, App State variables, and existing Custom Actions. This context awareness lets it generate code that references your specific variable names and matches your project's data structure.
Can I use Claude or Gemini instead of OpenAI for user-facing AI features?
Yes. Anthropic Claude and Google Gemini both have similar chat completion APIs. The server-side function pattern is the same — replace the OpenAI endpoint and API key with the Claude or Gemini equivalents. Claude (claude-3-5-haiku) is fast and cost-effective for chatbot use cases. Gemini 1.5 Flash is Google's equivalent.
How do I add a streaming response so the AI reply appears word by word?
Set stream: true in the OpenAI API request. In your Edge Function, use a streaming HTTP response. In FlutterFlow, streaming responses require a WebSocket or Server-Sent Events connection, which needs a Custom Widget. For most apps, a non-streaming approach with a loading indicator is simpler and sufficient.
Is there a FlutterFlow AI plan limit?
FlutterFlow AI chat is included on all plans. However, usage is subject to fair-use limits — the exact limits are not publicly documented but extremely heavy usage (hundreds of AI requests per day) may be throttled. For typical development use, you will not hit any limits.
Can I train FlutterFlow's AI on my own data or documentation?
No. FlutterFlow's AI is a fixed model trained on FlutterFlow's platform knowledge. You cannot customize it or add your own training data. For user-facing AI features that know about your product, use the RAG (retrieval-augmented generation) pattern: store your documentation in a vector database, retrieve relevant passages at query time, and include them in the system prompt sent to OpenAI or Claude.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation