# AI services

> This page is about FlutterFlow (the app builder you use by describing your app), not FlutterFlow Studio.

URL: https://docs.flutterflow.io/ffx/ai-services

Connect your OpenAI, Anthropic, or Google Gemini key, and then ask the agent for a feature that answers in text, billed to your provider account.

Add a feature that sends a request to OpenAI, Anthropic, or Google Gemini and shows the written answer, such as a summary, a suggestion, or a reply. Your app calls the service with your own key.

## Who pays {#who-pays}

Every AI call that your app makes is billed to the provider account that the key belongs to.

## Connect a key {#connect-your-key}

Each service needs one API key:

| Service | The key starts with | Where to create it |
|---|---|---|
| **OpenAI** | `sk-` | The OpenAI dashboard, under API keys. A project key works. |
| **Anthropic** | `sk-ant-` | The Anthropic Console, under API keys. |
| **Google Gemini** | `AQ.` or `AIza` | Google AI Studio, under API keys. |

A project owner connects the key:

1. Open **Project Settings › Connections**.
2. Turn on the switch for **OpenAI**, **Anthropic**, or **Google Gemini**. The **Connect *service*** dialog opens.
3. Paste your key into **API key**.
4. Click **Connect**.

The service checks the key before FlutterFlow saves it, and FlutterFlow never shows the key again.

<Mock name="connect-openai" alt="The Connect OpenAI dialog with an empty API key field, Find it beside its label, Encrypted at the foot, and Cancel and Connect." />

## Model and response length {#name-the-model}

Your app's AI calls use the model and the response length that the agent sets when it adds the feature, and people who use your app can't change them. Only people who are signed in to your app can use an AI feature.

If your request names neither, the app uses a default model and a default response length, which these docs don't list. So name both in your request:

- **Model:** each call's cost depends on the model. To see the models that your provider lists for your key, ask the agent to list them, and then name 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. Some models think before they answer and count that thinking toward the length, so give them a longer response length.

## What to ask

To ask for an AI feature, tell the agent what the feature does, which service and model it uses, and how long its answers can be. Replace [model name] with a model from your list:

> Example request: "Which models can my connected OpenAI key use?"

> Example request: "On each transaction, add a Suggest a category button that asks Google Gemini for a category based on the payee and the amount. Use [model name], and keep each answer to a few words."

> Example request: "Add a monthly summary to the budget screen that asks Anthropic to describe my spending in about 150 words. Use [model name]."

## Agent questions {#what-the-agent-may-ask-you}

If the service isn't connected, the agent shows a **Connect** ask above the message box, with a button such as **Connect OpenAI**. A project owner connects the service through that ask; anyone else is asked to get an owner to connect it. For more information, see [Connect a service](https://docs.flutterflow.io/ffx/connect-a-service).

## Review {#check-the-result}

After the agent finishes, read the turn's [**Summary**](https://docs.flutterflow.io/ffx/what-changed#summary) and review its [**Changes**](https://docs.flutterflow.io/ffx/what-changed#changes-tab). 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**](https://docs.flutterflow.io/ffx/thread-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. If an answer stops early, ask the agent for a longer response length.

## Push {#push-it}

After you test the feature, [push the changes to your app](https://docs.flutterflow.io/ffx/push).

## Next steps {#then}

- To replace the key or disconnect the service, see [Manage connections](https://docs.flutterflow.io/ffx/manage-connections).
- To see every service that you can connect, see [Available services](https://docs.flutterflow.io/ffx/services).

## Troubleshooting {#if-something-goes-wrong}

- **The service refuses your key:** see [A service refuses your key](https://docs.flutterflow.io/ffx/troubleshoot-connections#key-refused).
- **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 model that thinks first can use up the response length before it writes anything. Ask the agent for a longer response length.
- **A call takes too long and fails:** the service answers sooner with a shorter response length. Ask the agent for a shorter one, and try again.
- **Calls fail because of rate limits or credit:** check your account's limits and balance with the provider, and try again later. FlutterFlow also limits how often one connection can be called each minute, so wait a minute and try again.
- **Your app shows a message about the service:** see [Messages shown in your app](https://docs.flutterflow.io/ffx/troubleshoot-connections#app-messages).
