AI TikTok Script Writer Agent Skill — Generate Viral Scripts via API
AI TikTok Script Writer Agent Skill
Generate viral TikTok scripts with hooks, body copy, and captions via the AI Pass API. Use this skill when an agent workflow needs to produce TikTok-optimized video scripts.
Skill Overview
- Input: Topic/content idea + optional niche, style, tone
- Output: Complete TikTok script (hooks, body, CTA, caption, hashtags)
- Model:
gpt-5-minivia AI Pass - Auth:
$AIPASS_API_KEYenvironment variable
Skill File
name: tiktok-script-writer
description: Generate viral TikTok scripts with hooks, body content, CTAs and hashtags
parameters:
topic:
type: string
description: Content idea or topic for the TikTok video
niche:
type: string
description: Content niche (e.g. finance, fitness, cooking, tech)
default: "general"
style:
type: string
description: Video style (educational, storytime, listicle, controversial, pov, tutorial)
default: "educational"
length:
type: string
description: Target video length (e.g. 30 seconds, 1 minute)
default: "30-60 seconds"
tone:
type: string
description: Tone (engaging, funny, serious, inspirational, relatable)
default: "engaging"
returns:
type: object
description: Object with hook, script, cta, caption, hashtags fields
Implementation
import requests
import os
import re
AIPASS_API_KEY = os.environ["$AIPASS_API_KEY"]
def generate_tiktok_script(
topic: str,
niche: str = "general",
style: str = "educational",
length: str = "30-60 seconds",
tone: str = "engaging"
) -> dict:
"""
Generate a viral TikTok script via AI Pass.
Returns:
dict with keys: hook, script, cta, caption, hashtags
"""
prompt = f"""Write a viral TikTok script for the following:
Topic: {topic}
Niche: {niche}
Style: {style}
Video Length: {length}
Tone: {tone}
Provide exactly:
1. HOOK: 3 hook options for the first 3 seconds
2. SCRIPT: Full script with [ACTION] cues for visual moments
3. CTA: Call to action at the end
4. CAPTION: Caption text with 5-8 hashtags
Make hooks punchy and impossible to ignore. Write as spoken language."""
response = requests.post(
"https://aipass.one/apikey/v1/chat/completions",
headers={
"Authorization": f"Bearer {AIPASS_API_KEY}",
"Content-Type": "application/json"
},
json={
"model": "gpt-5-mini",
"temperature": 1,
"max_tokens": 16000,
"messages": [
{
"role": "system",
"content": "You are a viral TikTok content strategist. Write scripts that stop the scroll and drive engagement."
},
{"role": "user", "content": prompt}
]
},
timeout=60
)
content = response.json()["choices"][0]["message"]["content"]
# Parse sections
hook_match = re.search(r'HOOK[:\s]+([\s\S]*?)(?=SCRIPT:|$)', content, re.IGNORECASE)
script_match = re.search(r'SCRIPT[:\s]+([\s\S]*?)(?=CTA:|CAPTION:|$)', content, re.IGNORECASE)
cta_match = re.search(r'CTA[:\s]+([\s\S]*?)(?=CAPTION:|$)', content, re.IGNORECASE)
caption_match = re.search(r'CAPTION[:\s]+([\s\S]*?)$', content, re.IGNORECASE)
# Extract hashtags from caption
caption_text = caption_match.group(1).strip() if caption_match else ""
hashtags = re.findall(r'#\w+', caption_text)
return {
"hook": hook_match.group(1).strip() if hook_match else content[:300],
"script": script_match.group(1).strip() if script_match else content,
"cta": cta_match.group(1).strip() if cta_match else "",
"caption": caption_text,
"hashtags": hashtags,
"raw": content
}
# Example usage
if __name__ == "__main__":
result = generate_tiktok_script(
topic="3 things your financial advisor won't tell you about compound interest",
niche="Finance & Money",
style="Educational / Tips",
length="30-60 seconds",
tone="Engaging & Direct"
)
print("HOOK OPTIONS:")
print(result["hook"])
print("\nSCRIPT:")
print(result["script"])
print("\nCAPTION:")
print(result["caption"])
Notes for Agents
temperature: 1andmax_tokens: 16000are required for the GPT-5 model family- Response is parsed into structured fields; fall back to
rawif parsing fails - Typical response time is 5–15 seconds
- For batch script generation (e.g. content calendar), call sequentially with a 1-second delay
API Quick Reference
- Endpoint:
POST https://aipass.one/apikey/v1/chat/completions - Model:
gpt-5-mini - Auth:
Bearer $AIPASS_API_KEY - Get API Key: Developer Dashboard → API Keys