OpenAI
Add a feature that sends a request to an OpenAI model and shows the written answer, such as a summary, a suggestion, or a reply. You need an API key from the OpenAI dashboard.
Connect a key
To connect OpenAI, you must be a project owner. Everyone who can change the app can use OpenAI after an owner connects it. Create an API key in the OpenAI dashboard under API keys. The key starts with sk-, and a project key works.
- Open Project Settings › Connections.
- Turn on the switch for OpenAI. On a phone, tap OpenAI. The Connect OpenAI dialog opens.
- Connect a key in one of these ways:
- To reuse a key from another of your apps, click Use the key from that app. OpenAI connects at once.
- To use a new key, click Paste an API key if the dialog shows it, paste your key into API key, and then click Connect. To open the OpenAI API keys page, click Find it beside the label.
OpenAI checks the key before FlutterFlow saves it, and FlutterFlow never shows the key again.
Cost and model
Every AI call that your app makes is billed to the provider account that the key belongs to.
Your app’s AI calls use the model and the response length that the feature is built with, and people who use your app can’t change them. Name both in your request:
- Model: each call’s cost depends on the model. To see the models that you can name, ask the agent to list them, and then pick one.
- Response length: the longest answer that each call pays for. When an answer reaches it, the service stops, even in the middle of a sentence.
What to ask
To ask for an OpenAI feature, tell the agent what the feature does, that it uses OpenAI, which model it uses, and how long its answers can be. Replace [model name] with a model that the agent lists for your key:
Which models can my connected OpenAI key use?
Add a monthly summary to the budget screen that asks OpenAI to describe my spending in about 150 words. Use [model name].
On each transaction, add a Suggest a note button that asks OpenAI for a short note based on the payee and the amount. Use [model name], and keep each answer to one sentence.
Agent questions
If OpenAI isn’t connected, the agent asks you to connect it, with a Connect OpenAI button that opens the same dialog. If you aren’t a project owner, ask one to connect OpenAI. For more information, see Connect a service.
Review
After the agent finishes, read the turn’s Summary and review its Changes. Check the affected screens in Screens, and try the change in Preview. If the change uses records or sign-in, test it with the thread’s own data in Data.
After you push a backend change, check the result in Backend.
Try the feature in the preview a few times and read the answers.
Push
After you test the feature, push the changes to your app.
Next steps
- To replace the key or disconnect OpenAI, see Manage connections.
- To see the other services that you can connect, see Services.
Troubleshooting
- OpenAI refuses your key: see A service refuses your key.
- The dialog says that your key looks like an Anthropic or OpenRouter key: OpenAI keys start with
sk-, but notsk-ant-orsk-or-. Connect that key as Anthropic or OpenRouter instead, or create an OpenAI key. - The dialog says that OpenAI API keys start with
sk-: the key isn’t a whole OpenAI key. Copy the whole OpenAI key from the OpenAI dashboard, and paste it again. - Calls stop working after you delete or rotate the key: create a new key in the OpenAI dashboard, and then replace the key.
- Answers stop in the middle of a sentence: the response length is too short for the model. Ask the agent for a longer response length.
- A call fails without any answer: a reasoning model can use up the response length before it returns any text. Ask the agent for a longer response length. If the response length is already at its longest, ask the agent for a different model.
- OpenAI declines a prompt: trying the same prompt again usually doesn’t help. Change the prompt.
- A call takes too long and fails: OpenAI answers sooner with a shorter response length. Ask the agent for a shorter one, and try again.
- Calls fail because the account is out of credit: add credit, or raise your spending limit, in the OpenAI dashboard, and then try again.
- Calls fail because of rate limits: FlutterFlow limits how often one connection can be called each minute, so wait a minute and try again. If the message says that OpenAI is rate limiting requests, OpenAI’s own limit was reached. Wait as long as the message says, and then try again.
- Your app shows a message about the service: see Messages shown in your app.