Add AI features
Add a chatbot, AI search, or an AI agent to your app using your own provider API key
Ask the agent for an AI feature and it builds both halves: the interface your users see, and a secure server function that holds your provider API key. You supply the key once, in the Supabase connection dialog. The key never appears in your app's code and is never visible in the chat.
When to use it
Use this when your app should do something a language model does: answer questions, chat, summarise, generate text, search your own content by meaning, or run an agent that takes actions on a user's behalf.
What you need
- An account at plutoai.one.
- Supabase connected. The AI part of your app runs on Supabase, so this is the one provider that is required. See Connecting your tools.
- An API key from an AI provider, such as OpenAI or Anthropic. You get this from the provider, not from PlutoAI, and it is billed by them.
Why the key does not go in your code
Anything in your app's frontend code ships to your users' browsers, so a key put there can be read and spent by anyone who opens the page. Instead, the agent puts every AI call inside a server function on your Supabase project. Your app calls the function; the function holds the key.
That means the key is a setting on your project, not part of your codebase. You paste it in once, and it stays out of your repository, out of the chat, and out of anything you deploy.
Steps
- Connect Supabase
Connect Supabase and select the project this app should use.
- Describe the AI feature
Tell the agent what you want, in product terms. It writes the interface and the server function together.
- Paste your provider key
Open the Supabase connection dialog and find "Edge Function secrets." Enter the name the agent used, for example
OPENAI_API_KEY, and paste the key as its value, then save. The agent's summary tells you which names it read. - Try it in the preview
Use the feature in the running app. Ask a question, send a message, run the flow end to end.
You do not deploy the server function yourself. It goes live on your Supabase project as the agent writes it, as long as Supabase is connected.
Example prompt
I've connected Supabase. Add an AI assistant to my app: a chat panel
where a user types a question and the answer streams back a word at a
time. Keep my API key on the server, and show a clear message if the
key isn't set yet.
Realistic follow-ups:
Let users ask questions about the documents they've uploaded, and cite
which document each answer came from.
Add a per-user limit so one person can't run up my provider bill.
What each kind of feature involves
| You ask for | What gets built |
|---|---|
| A chatbot or assistant | A chat interface with streamed replies, plus a server function that calls the provider and keeps conversation history. |
| Search over your own content | Storage for your content and a similarity search over it, so answers come from your material rather than the model's general knowledge, with sources shown. |
| An AI agent | A loop that decides, uses tools you define, checks the result, and repeats until the task is done, with a step limit so it cannot run away. |
| Summaries or generated text | A server function per task, called from the page that needs it. |
Expected result
The feature works in the preview once your key is saved. Answers stream in, and if a request fails your app shows a plain message instead of spinning forever.
Common problems
- The feature says AI is not switched on yet. Either Supabase is not connected, or the key has not been saved. Check both in the Supabase connection dialog.
- The key is saved but requests fail. Confirm the secret name matches what the agent used exactly, including case, and that the key is still valid with your provider.
- Answers are confidently wrong. A model with nothing to draw on will invent. Ask for search over your own content so answers are grounded in your material.
- Costs climb faster than expected. Provider usage is billed by the provider. Ask the agent for a per-user limit and a cap on response length.
Your AI provider bills you directly for what your app uses. That is separate from your PlutoAI plan.