AI Text Tool API

Single endpoint that powers every Tools Lab PRO AI Studio tool — YouTube SEO, prompt utilities, hooks, captions, design briefs and more.

One endpoint
All AI tools share POST /ai-text-tool.
Auth via anon key
Send the publishable key in Authorization + apikey headers.
JSON in / JSON out
Returns { text: string } on success.

Endpoint

POST https://ksajsnsdvhzonfmlyyqk.supabase.co/functions/v1/ai-text-tool

Authentication

The endpoint requires the project publishable (anon) key. Send it on every request:

Required headers
Content-Type: application/json
Authorization: Bearer <ANON_KEY>
apikey: <ANON_KEY>

The publishable key is safe to expose in client-side apps. The server-side LOVABLE_API_KEY is never exposed — calls are proxied through the edge function so credits stay on Tools Lab PRO's account.

Request body

JSON shape
{
  "kind": string,           // see "kinds" table below
  "input": string,          // 1 - 8000 chars; longer values are truncated
  "options": {              // tool-specific (optional)
    "platform"?: "Instagram" | "X" | "LinkedIn" | "TikTok" | "Threads",
    "style"?: "cinematic" | "anime" | "realistic" | "watercolor",
    "length"?: "60 seconds" | string,
    "kind"?: string,        // for design-brief, e.g. "Color palette (5 hex)"
    "lang"?: string         // for multi-language tts brief
  }
}

Examples

cURL
curl -X POST 'https://ksajsnsdvhzonfmlyyqk.supabase.co/functions/v1/ai-text-tool' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtzYWpzbnNkdmh6b25mbWx5eXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Nzc1NTk0NzksImV4cCI6MjA5MzEzNTQ3OX0._eYU1hTfNmtGH3zmtdSjsA9j_Vgey0sYwhqOsR-2KH0' \
  -H 'apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtzYWpzbnNkdmh6b25mbWx5eXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Nzc1NTk0NzksImV4cCI6MjA5MzEzNTQ3OX0._eYU1hTfNmtGH3zmtdSjsA9j_Vgey0sYwhqOsR-2KH0' \
  -d '{
    "kind": "yt-title",
    "input": "best AI video editor 2026",
    "options": {}
  }'
JavaScript / TypeScript (Supabase client)
import { supabase } from "@/integrations/supabase/client";

const { data, error } = await supabase.functions.invoke("ai-text-tool", {
  body: {
    kind: "youtube-combo",
    input: "I tried 10 AI tools so you don't have to",
    options: {}, // tool-specific (see kinds below)
  },
});

if (error) throw error;
console.log(data.text);
200 OK
{
  "text": "1. The AI Tool That Almost Replaced My Editor\n2. ..."
}
Error response
{
  "error": "Rate limit exceeded. Try again in a moment."
}

Error codes

StatusMeaningAction
400Unknown kind or empty inputCheck the kinds table below.
401 / 403Missing or invalid anon keyAdd both headers above.
402AI credits exhaustedOwner must top up credits in Workspace › Usage.
429Upstream rate limit hitBack off and retry; the SDK does this automatically.
500 / 502 / 503Upstream model failureRetry with exponential back-off.

Supported kind values

kindDescriptionRecommended options
yt-titleYouTube title generator (8 viral titles)
yt-descriptionYouTube SEO description
yt-tagsYouTube tags (25-30, comma-separated)
yt-hookYouTube 5-second hook
youtube-comboFull YouTube SEO bundle
prompt-improverImprove / strengthen an AI prompt
prompt-expanderExpand short prompt to detailed prompt
prompt-styleConvert prompt stylestyle
veo3-promptCinematic Veo 3 video prompt
veo3-consistency5 consistent Veo 3 shots
image-to-promptImage description → Flux/SD prompt
viral-postViral social postplatform
thread-makerX / LinkedIn threadplatform
caption-genPlatform captionplatform
hashtag-strategyHashtag strategyplatform
hook-gen10 scroll-stopping hooks
carousel-genIG / LinkedIn carousel slides
bio-genBio generatorplatform
audience-persona3 detailed audience personas
strategy-planner90-day content strategy
design-briefDesign brief (poster, banner, palette…)kind

See the source list of all 50+ kinds in supabase/functions/ai-text-tool/index.ts.