Skip to main content
Orq.ai manages the GenAI layer while Lovable builds the interface from prompts. There is nothing to install: the path here is a snippet, one prompt, and a server-side function that holds the key. This guide builds a FAQ chatbot. The browser calls a Supabase Edge Function, which holds the Orq.ai API key and forwards each message to the AI Gateway. The key never reaches the frontend.

What We Will Build

Architecture flow
  1. A user sends a message in the Lovable chat UI.
  2. The frontend calls a Supabase Edge Function.
  3. The edge function calls the AI Gateway at https://my.orq.ai/v3/router/responses with "model": "agent/<agent_key>", sending the API key it holds.
  4. The response returns through the edge function and renders in the chat.

Step 1: Set Up Orq.ai

Three settings cause most failed first calls, so do them first. Create an API key. Open Settings > API Keys and create a key for the project the chatbot belongs to. Copy it from the dialog that appears once, and treat it as a server-side secret from then on. See API Keys. Enable a model. Open AI Gateway > Model List and switch the model on with the Status toggle. A disabled model is rejected even with a valid key. The model ID sits in the Name column and takes the provider/model form, for example openai/gpt-5.6-sol. See Supported Models for the catalog.
Model List showing the Status toggle column and the Name column with provider-prefixed model IDs.

The Model List, where the Status toggle enables a model.

Create the agent. Open Agents in the Managed Agents section of the AI Studio, click Agent, and set an Agent Key such as faq-bot. Give it the model enabled above and instructions for the FAQ chatbot. The app calls the agent rather than the model, so this key is what the edge function sends. See Build Agents.
Create Agent dialog with gpt-5.6-sol selected, Agent key faq-bot, Path 0-Demo and a description for the FAQ chatbot.

The Create Agent dialog, with the model, Agent Key and description set.

Step 2: Add the AGENTS.md Snippet

Lovable’s documentation states that root-level AGENTS.md files are always read by the Lovable agent, while skills load only when a request matches their description. The always-read file is therefore the reliable place for the facts the builder must not invent. Create AGENTS.md in the project root and paste:

Step 3: Build the Interface With One Prompt

With the snippet in place, one prompt builds the chat UI and wires it to the Gateway:
Lovable generates the layout and the calling code. Adjust styling with follow-up prompts; the shape of the backend integration does not change.

Step 4: Store the Key in a Supabase Edge Function

If the project has no Supabase connection yet, click the Supabase icon in the Lovable sidebar and go through the steps it presents. Then open the Lovable chat and prompt:
Ask Lovable to create the edge function, then add the Orq.ai API key as a secret for that function in its secret store rather than in the chat: a value pasted into the conversation is kept in its history and can be echoed into generated code. The edge function is what keeps the key out of the browser: the frontend never sees it, and the secret is only read server-side at request time. The function URL is public, so authorize the caller inside the function before forwarding: require a signed-in session and reject unauthenticated requests, and cap how many requests one caller can make.
Lovable chat next to the Supabase Edge Functions secrets form with an API key being added

Supabase edge function secrets, where the Orq.ai API key is entered outside the chat.

Lovable chat confirming the key was added to Supabase secrets and will be used from an edge function instead of frontend code

Lovable updating the project once the secret is stored in the edge function.

Step 5: Ground Answers in a Knowledge Base

The agent answers from the model’s own knowledge until a knowledge base is attached. Attaching it does not change the request, so the architecture from Step 3 does not change.
  1. Open Knowledge Bases under Managed Agents in the sidebar and create one. See Knowledge Bases for the datasource and chunking options.
  2. Add the source documents with Add datasource. Orq.ai splits each file into chunks and processes them, and the processed chunk count appears next to the file.
  3. Open the agent, click Add context in the Settings panel, and select the knowledge base. The query_knowledge_base and retrieve_knowledge_bases tools are added to the agent automatically, and the agent queries the knowledge base during a conversation when it needs it. Write an explicit description on the knowledge base: the agent reads that description to decide when to query it. See Build Agents.
Agent Settings panel with Add context open, a search for product and the product_docs knowledge base listed.

Select the knowledge base from Add context in the agent's Settings panel.

Step 6: Test and Iterate

Run a few conversations and confirm the answers arrive. Then verify the key stays server-side:
  1. Open the browser developer tools, go to the Network tab, and send a message. The request goes to the Supabase Edge Function; no request carries the Orq.ai API key, and no request goes to my.orq.ai.
  2. Open Traces in Orq.ai and confirm the call appears there, which proves it reached the Gateway with a valid key.
If something does not work, ask Lovable:

Feedback Collection (Optional)

Feedback in Orq.ai helps track response quality and identify areas for improvement. Collect user ratings, defect classifications, and corrections to continuously enhance the application. Provide feedback through the AI Studio:
  1. Go to Logs in your workspace
  2. Find the specific invocation
  3. Use the feedback interface to rate responses
  4. Add defect classifications or corrections as needed

Next Steps

The result is a chatbot where Orq.ai handles the GenAI layer, Lovable handles the interface, and the API key stays in a server-side function. The same pattern applies to customer support, internal knowledge assistants, or onboarding bots. For questions or feedback, reach out to us at support@orq.ai.