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
| Status | Meaning | Action |
|---|---|---|
| 400 | Unknown kind or empty input | Check the kinds table below. |
| 401 / 403 | Missing or invalid anon key | Add both headers above. |
| 402 | AI credits exhausted | Owner must top up credits in Workspace › Usage. |
| 429 | Upstream rate limit hit | Back off and retry; the SDK does this automatically. |
| 500 / 502 / 503 | Upstream model failure | Retry with exponential back-off. |
Supported kind values
| kind | Description | Recommended options |
|---|---|---|
| yt-title | YouTube title generator (8 viral titles) | — |
| yt-description | YouTube SEO description | — |
| yt-tags | YouTube tags (25-30, comma-separated) | — |
| yt-hook | YouTube 5-second hook | — |
| youtube-combo | Full YouTube SEO bundle | — |
| prompt-improver | Improve / strengthen an AI prompt | — |
| prompt-expander | Expand short prompt to detailed prompt | — |
| prompt-style | Convert prompt style | style |
| veo3-prompt | Cinematic Veo 3 video prompt | — |
| veo3-consistency | 5 consistent Veo 3 shots | — |
| image-to-prompt | Image description → Flux/SD prompt | — |
| viral-post | Viral social post | platform |
| thread-maker | X / LinkedIn thread | platform |
| caption-gen | Platform caption | platform |
| hashtag-strategy | Hashtag strategy | platform |
| hook-gen | 10 scroll-stopping hooks | — |
| carousel-gen | IG / LinkedIn carousel slides | — |
| bio-gen | Bio generator | platform |
| audience-persona | 3 detailed audience personas | — |
| strategy-planner | 90-day content strategy | — |
| design-brief | Design brief (poster, banner, palette…) | kind |
See the source list of all 50+ kinds in supabase/functions/ai-text-tool/index.ts.