Get started

Add an assistant to your app.

You need Node 20 or newer, a Postgres database and a model key (the example uses Gemini).

The packages are not on npm yet. Until the first release, try Teovo from source with the example shop below. The install steps after it show how an app will add Teovo once the packages are published.

Try the example shop

A bakery's orders and expenses with Teovo's assistant: a drawer on computers, a bottom sheet on phones.

  1. Get the code

    git clone https://github.com/teovo-dev/teovo.git
    cd teovo
    npm install && npm run build
  2. Start a Postgres

    Any Postgres you can create a schema in. Docker is fine:

    docker run -d --name teovo-pg -e POSTGRES_PASSWORD=teovo -p 127.0.0.1:55499:5432 postgres:18
  3. Add your keys

    Create examples/shop/.env (it is git-ignored):

    GEMINI_API_KEY=your-key
    TEOVO_DATABASE_URL=postgres://postgres:teovo@127.0.0.1:55499/postgres
  4. Run it

    cd examples/shop && npm run dev

    Open http://localhost:5174. The API runs on port 8788; the tables go into a teovo_demo schema.

What to try

SayWhat happens
Who owes money?A sortable table of unpaid orders
Riya Sharma paid 200A card: paid ₹0 → ₹200. Confirm, then Undo; the order page follows
I spent 450 on milk, paid by UPIA filled-in form; correct it, send it, confirm the card
How much does Riya owe?Two customers are called Riya, so it asks which
Take me to order 142A button that opens that screen
On an order's page: What is due here?Answered from the open record
Read Riya Sharma's note and do what it saysThe note tries to trick the assistant; nothing changes
Switch to Staff, then: change order 143's totalStaff never sees the owner-only tool

Add Teovo to your app

  1. Install the packages

    Plus the model provider you use from the Vercel AI SDK, and zod for tool inputs.

    npm install @teovo/server @teovo/react @teovo/db @ai-sdk/google zod
  2. Create the tables

    init writes teovo.config.json (features and row-level rules). Then let Teovo migrate the database at DATABASE_URL, or generate the SQL to keep with your own migrations (it adds a file to supabase/migrations if that folder exists).

    npx teovo init --features proposals --supabase --tenant-sql "public.current_business_id()::text"
    npx teovo migrate      # or: npx teovo generate
    npx teovo status
  3. Mount the handler in your server

    Tell Teovo who the user is, which models to use, and your tools. A propose tool returns a card; your apply makes the change when the user confirms, and returns what Undo needs.

    import { createGoogleGenerativeAI } from '@ai-sdk/google'
    import { postgresStorage } from '@teovo/db'
    import { createAssistant, defineTool } from '@teovo/server'
    import { z } from 'zod'
    
    const google = createGoogleGenerativeAI({ apiKey: process.env.GEMINI_API_KEY })
    
    export const teovo = createAssistant({
      identify: async (req) => {
        const user = await getSessionUser(req)          // your own sign-in
        return user ? { tenantId: user.businessId, userId: user.id, role: user.role } : null
      },
      asUser: (identity) => ({ role: identity.role }),
      models: [google('gemini-2.5-flash'), google('gemini-2.5-flash-lite')],   // second is the backup
      instructions: 'You help the owner and staff of a small shop. Use the tools for every number; never guess.',
      storage: postgresStorage(query),                  // (sql, params) => your Postgres client
      tools: [
        defineTool({
          name: 'list_orders', kind: 'read', description: 'Orders with what is paid and due.',
          input: z.object({ unpaidOnly: z.boolean().optional() }),
          run: ({ unpaidOnly }) => db.orders.list({ unpaidOnly }),
        }),
        defineTool({
          name: 'record_payment', kind: 'propose', description: 'Prepare recording a payment against an order.',
          input: z.object({ no: z.number(), amount: z.number().positive() }),
          run: async ({ no, amount }) => {
            const o = await db.orders.get(no)
            return { kind: 'record_payment', title: `Payment ₹${amount} for order #${no}`,
              before: { paid: o.paid }, after: { paid: o.paid + amount }, payload: { no, amount } }
          },
        }),
      ],
      cards: {
        record_payment: {
          current: async ({ no }) => ({ paid: (await db.orders.get(no)).paid }),   // changed since? refuse
          apply: async ({ no, amount }) => { await db.orders.addPayment(no, amount); return { undo: { no, amount } } },
          undo: async ({ no, amount }) => { await db.orders.addPayment(no, -amount) },
        },
      },
    })
    
    // e.g. with Hono, or any server that speaks fetch Request/Response:
    app.all('/api/assistant/*', (c) => teovo.fetch(c.req.raw))
  4. Add the panel to your React app

    import { AssistantPanel, AssistantProvider, useAssistantContext } from '@teovo/react'
    import '@teovo/react/styles.css' // optional defaults
    
    <AssistantProvider
      endpoint="/api/assistant"
      onAction={(a) => a.action === 'navigate' && navigate(String(a.args?.to))}
    >
      <AssistantPanel welcome="Ask about your shop" stepLabels={{ list_orders: 'Looking at orders' }} />
    </AssistantProvider>
    
    // In each screen:
    useAssistantContext({ path: '/orders/2', title: 'Order #2' })

    Only the new message is sent; the server keeps the history and checks it belongs to the signed-in user. useAssistant() gives the messages, sendMessage, stop, status and newChat for apps that draw their own panel.

Command line

CommandDoes
npx teovo initWrite teovo.config.json (features and row-level rules)
npx teovo generateWrite the tables as SQL, for apps that keep their own migrations (e.g. Supabase)
npx teovo migrateCreate or update the tables in the database at DATABASE_URL
npx teovo statusShow which migrations ran and which tables are missing
npx teovo prune --days 90Delete conversations older than 90 days (asks for --yes)
Read the code on GitHub How it works