build strategy · AIsa

Real AIsa, one key, one build.

Every mega-prompt in this archive collapses into the same shape: a single TanStack server function calling api.aisa.one with one secret. It's the only pattern that lets a Lovable account ship a working AIsa demo in one shot, inside the 5-credit budget.

Why AIsa and not a single provider?

AIsa gives you one OpenAI-compatible endpoint and one API key in front of every frontier model — OpenAI, Anthropic, Google, Qwen, DeepSeek for chat; Seedream + GPT image for stills; Wan + Seed for video; Tavily, YouTube, scholar and more as Skills. Swap models by changing one string, never touch infra.

Why TanStack server functions?

Lovable's TanStack Start template makes secrets trivial. createServerFn runs on the server, reads process.env.AISA_API_KEY, hits AIsa, and returns typed JSON. The key never reaches the browser, no edge functions or extra infra needed.

The pattern in code.

src/lib/aisa.functions.ts — chat
// src/lib/aisa.functions.ts — TanStack server function calling AIsa chat completions
// Built during the AIsa Creative Hackathon — StreetKode Fam · Indian Krump Festival 14
import { createServerFn } from "@tanstack/react-start";
import { z } from "zod";

export const ask = createServerFn({ method: "POST" })
  .inputValidator((d) => z.object({ topic: z.string().min(1).max(2000) }).parse(d))
  .handler(async ({ data }) => {
    const r = await fetch("https://api.aisa.one/v1/chat/completions", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${process.env.AISA_API_KEY!}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        model: "openai/gpt-4o-mini",
        messages: [{ role: "user", content: data.topic }],
      }),
    });
    if (!r.ok) throw new Error(`AIsa failed: ${r.status}`);
    const j = await r.json();
    return { reply: j.choices[0].message.content as string };
  });
src/lib/aisa.functions.ts — image
// src/lib/aisa.functions.ts — same key, generate an image
export const render = createServerFn({ method: "POST" })
  .inputValidator((d) => z.object({ brief: z.string().min(1).max(800) }).parse(d))
  .handler(async ({ data }) => {
    const r = await fetch("https://api.aisa.one/v1/images/generations", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${process.env.AISA_API_KEY!}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        model: "bytedance/seedream-3.0",
        prompt: data.brief,
        size: "1024x1024",
      }),
    });
    if (!r.ok) throw new Error(`AIsa image failed: ${r.status}`);
    const j = await r.json();
    return { url: j.data[0].url as string };
  });
.env + Lovable build
# .env (Lovable -> Project Settings -> Secrets)
AISA_API_KEY=sk-aisa-...      # https://console.aisa.one

# How Lovable wires this up in one prompt:
# 1. Paste a mega-prompt from this archive.
# 2. Lovable
#    - writes a server function that proxies AIsa (chat / image / video / skills)
#    - wires the client surface (textarea, prompt-to-canvas, search box, etc.)
#    - keeps your key on the server via process.env.AISA_API_KEY
# 3. Run it. Your demo is calling real AIsa frontier models.

Shipping a 5-credit demo