AI Copilot

The fastest way to build with Spala — describe what you need in plain English and the AI builds your entire backend.

AI Copilot

The fastest way to build with Spala. Describe what you need in plain English and the AI creates your database tables, functions, and API endpoints in seconds.

This is how most people build with Spala

Skip the step-by-step setup. Tell the AI Copilot what you want, review the changes, and apply.

The AI Copilot panel open in Build mode showing context tabs and prompt area
Open the AI Copilot (⌘J) and describe what you want to build

Build a complete feature in 30 seconds

Describe what you need

Open the AI Copilot with ⌘J (or click the AI button in the header) and type what you want. Be as specific as you like:

> "I need a booking system where users can reserve time slots, cancel bookings, and get email confirmations. Each booking has a date, time, duration, and status."

The AI understands your intent and figures out the right tables, functions, and endpoints.

Review the diff

The AI generates a complete set of changes and shows them as a diff, exactly like a pull request. You see every table, function, and endpoint that will be created or modified. Nothing changes until you approve it.

Apply with one click

Click Apply to add the feature to your project draft: tables created, functions wired up, endpoints ready to test. Test it in the Playground, then publish when you are ready. If Autopublish is enabled, Spala can publish after applying.

What the AI Copilot creates for you

A single prompt can generate:

- Database tables with the right fields, types, and relationships
- Functions with queries, conditions, validation, and error handling
- API endpoints with proper methods, paths, and authentication
- Addon integrations like email notifications or payment processing
The AI Copilot showing a diff of proposed changes with tables and endpoints
The AI generates a full diff — review every change before applying

Context tabs

The AI Copilot shows your project context across several tabs at the top of the panel:

- General — Project-wide settings and overview
- Data — Database tables and relationships the AI considers
- Functions — Existing backend logic the AI can reference or extend
- API — Current endpoints and routes
- Tasks — Scheduled and background tasks
- Triggers — Database change triggers and event handlers

These tabs let you see exactly what context the AI has when generating changes. The AI reads your entire project structure to produce accurate, compatible output.

Additional Context

Click Additional Context (below the context tabs) to add custom instructions that are included in every AI request. Use this for:

- Coding conventions ("Always add created_at and updated_at timestamps")
- Business rules ("All prices should be stored in cents")
- Tech stack preferences ("Use the email addon for notifications")
The Additional Context text area expanded in the AI Copilot panel
Add custom context that the AI includes in every request

Copilot settings

Click the ⋮ menu in the copilot header to configure:

| Setting | What it does |
|---|---|
| PRO mode | Uses a more capable AI model for complex prompts |
| Autopublish | Automatically publishes changes after applying (skips the manual publish step) |
| Test with AI | Has the AI review its own generated changes for quality before you apply |

You can also toggle PRO mode and Test with AI directly from the badges below the context tabs.

Write better prompts

The more context you give, the better the result:

| Good prompt | Why it works |
|---|---|
| "A tasks table with title, status, priority, due_date, and assigned_to (references users)" | Specifies fields and relationships |
| "When a task is marked complete, send an email to the project owner" | Describes behavior, not implementation |
| "GET /api/tasks should support filtering by status and sorting by due_date" | Specifies API contract |
| "If the time slot is already booked, return a 409 error" | Includes edge cases |

AI Copilot + manual editing

The AI Copilot is your starting point, not a replacement for the visual editor. A typical workflow:

1. AI Copilot creates the feature scaffolding (tables, functions, endpoints)
2. Visual editor lets you fine-tune individual steps and conditions
3. Code view gives you full JavaScript control when you need it

You can also use the AI Copilot to modify existing features: "Add pagination to the list products endpoint" or "Add a discount_code field to the orders table."

When to use what

| Start with AI Copilot | Build manually |
|---|---|
| New features from scratch | Fine-tuning an existing function |
| Standard patterns (CRUD, auth, search) | Complex custom business logic |
| Rapid prototyping | Precise control over every step |
| Setting up database + endpoints together | Working with niche addon configurations |

Ask questions about your project

The AI Copilot in Ask mode for querying your project
Switch to Ask mode to chat about your project
Switch to Ask mode to chat with the AI about your project. Ask things like:
- "Which endpoints use the orders table?"
- "How does the login flow work?"
- "What addons are installed?"

The AI searches across your entire project to give you accurate, referenced answers.

AI Data Access

By default, Ask mode only sees your project structure (tables, functions, endpoints). To let the AI query actual data from your database, enable AI Data Access in Settings > AI.

The AI Data Access settings page showing table access configuration
Configure which tables and fields the AI can query in Ask mode
With Data Access enabled, you can ask questions like:
- "How many users signed up this week?"
- "Show me the last 10 orders with status 'pending'"
- "What is the average order value?"

You control exactly which tables and fields the AI can access:

- Enable/disable per table — Toggle access for each table individually
- Field-level control — Select which fields the AI can see (exclude sensitive columns like password hashes)
- Max rows per table — Limit how many rows the AI can query (default: 20)
- Allow Aggregates — Enable COUNT, SUM, AVG, MIN, MAX queries

AI Data Access uses read-only SELECT queries only. The AI cannot modify, insert, or delete data. Review which fields you expose — avoid granting access to columns with sensitive information.

Quality review

After the AI generates changes, toggle Test with AI to have it review its own work. The AI:
- Scores each generated item for quality
- Identifies gaps (missing validation, error handling, edge cases)
- Suggests fixes you can apply with one click

This catches issues before you apply changes to your project.

Quick Start
/getting-started/quickstart
Build your first API step by step
Lite Mode
/features/lite-mode
Use the Copilot workspace and project graph
Addons
/addons
Add payments, email, AI, and more to your functions