Skip to main content

Content Generation

Generate podcast content using AI (Anthropic Claude) with RAG-enhanced prompts from the Pinecone knowledge base.

Generate PRF

Generate a PRF (Podcast Repurposing Framework) document from a transcript.
POST /api/ai/prf
curl -X POST https://production.youvebeenheard.com/api/ai/prf \
  -H "Content-Type: application/json" \
  -H "Cookie: auth_token=<token>" \
  -d '{
    "transcript": "Full episode transcript...",
    "systemPrompt": "Generate a PRF...",
    "useRAG": true
  }'

Request

transcript
string
required
Full episode transcript (max 100,000 characters)
systemPrompt
string
required
System prompt with generation instructions
useRAG
boolean
default:true
Enable RAG context from Pinecone knowledge base (brand guidelines, writing style)
ragQuery
string
Custom RAG query (defaults to first 500 chars of transcript)

Response

{
  "content": "# Podcast Repurposing Framework\n\n## Core Message\nChris Pacifico explains..."
}
content
string
Generated PRF document (Markdown format)

RAG Context

When useRAG: true, the system:
  1. Generates embedding for ragQuery (or transcript excerpt)
  2. Queries Pinecone for relevant context from:
    • brand-manual - YBH brand guidelines
    • anti-ai-writing-guide - Writing style rules
    • brand-narrative - Brand voice examples
  3. Appends context to system prompt
Example RAG context appended:
═══════════════════════════════════════════════════════════════════
KNOWLEDGE BASE CONTEXT (Use for reference)
═══════════════════════════════════════════════════════════════════

[Brand Manual - Voice]
We don't sell. We unsell. Anti-spin, Anti-transactional, Pro-IT leader.

---

[Anti Ai Writing Guide - Avoid]
Don't use phrases like "In today's rapidly changing world" or "Let's dive in".

Model Configuration

Uses Claude Sonnet 4 (claude-sonnet-4-20250514):
  • Max tokens: 8,192
  • Temperature: Not specified (defaults to 1.0)
  • System prompt: Enhanced with RAG context

Generate Viral Hooks

Generate viral social media hooks from PRF.
POST /api/ai/hooks
curl -X POST https://production.youvebeenheard.com/api/ai/hooks \
  -H "Content-Type: application/json" \
  -d '{
    "prf": "PRF document...",
    "systemPrompt": "Generate viral hooks...",
    "useRAG": true
  }'

Request

prf
string
required
PRF document (Markdown or text)
systemPrompt
string
required
System prompt with hook generation instructions
useRAG
boolean
default:true
Enable brand voice context from Pinecone

Response

{
  "content": "<h2>Hook 1: The Hidden Cost</h2>\n<p>Most IT leaders...</p>"
}
content
string
Generated viral hooks (HTML format with TipTap-compatible structure)
Fact Verification: Best practice is to include the original transcript in the PRF input to enable fact-checking:
const prfInput = `SOURCE TRANSCRIPT (for fact verification):\n${transcript}\n\n═══...═══\nPRF ANALYSIS:\n${prf}`

Generate Infographic Spec

Generate infographic design specifications with layout, colors, and content structure.
POST /api/ai/infographic
curl -X POST https://production.youvebeenheard.com/api/ai/infographic \
  -H "Content-Type: application/json" \
  -d '{
    "selectedText": "Text to visualize...",
    "episodeContext": "Episode 385: Chris Pacifico...",
    "history": ["Doom Loop", "Quadrant Matrix"],
    "designType": "infographic",
    "systemPrompt": "Design an infographic..."
  }'

Request

selectedText
string
required
Text excerpt to visualize
episodeContext
string
required
Episode metadata and context (episode number, guest, transcript excerpt)
history
string[]
required
Previously used infographic types (for variety)
designType
string
default:"infographic"
Design type: infographic, quote, or thumbnail
systemPrompt
string
required
System prompt with design instructions
useRAG
boolean
default:true
Enable design database context from Pinecone

Response

{
  "spec": {
    "layout": "Pyramid (Bottom-Up)",
    "template": "Strategic Framework",
    "title": "The Three Pillars of IT Leadership",
    "colorSystem": "Corporate Professional",
    "iconStyle": "isometric",
    "aspectRatio": "16:9",
    "contentBreakdown": {
      "mainMessage": "IT leaders need three core skills",
      "sections": ["Technical Expertise", "Business Acumen", "People Leadership"],
      "dataPoints": ["70% of CIOs", "3-5 years average tenure"]
    },
    "prompt": "Create a professional isometric infographic..."
  }
}
spec
object
Infographic design specification

Design Database Context

When useRAG: true, queries Pinecone for:
  • Layout structures (28 types): Circular, Linear, Comparison, Grid, etc.
  • Content templates (10 types): Doom Loop, Strategic Framework, Journey Map, etc.
  • Visual style systems: Icon styles, color palettes, typography rules
Skips RAG for designType: "quote" (doesn’t need layout templates).

Default Specs by Design Type

{
  "layout": "Card Grid",
  "template": "Strategic Framework",
  "title": "Key Insight",
  "colorSystem": "Corporate Professional",
  "iconStyle": "isometric",
  "aspectRatio": "16:9",
  "prompt": "<selectedText>"
}

Error Responses

All content generation endpoints return consistent error responses:
StatusErrorDescription
400Transcript is requiredMissing required input
400PRF is requiredMissing required PRF input
400Selected text is requiredMissing infographic input
500Anthropic API key not configuredMissing API key
500Anthropic API errorUpstream API error
500Failed to generate [content]Generation error

Rate Limiting & Costs

API Costs: Content generation uses the Anthropic Claude API, which incurs costs per request:
  • PRF generation: ~$0.10-0.30 per episode (8K tokens)
  • Hooks generation: ~$0.05-0.15 per set (4K tokens)
  • Infographic specs: ~$0.03-0.08 per spec (2K tokens)
Monitor usage via Anthropic dashboard.
No Built-in Rate Limiting: Content generation endpoints do not enforce rate limits. Implement client-side rate limiting or request throttling as needed.

Best Practices

1. Include Source Transcript

For fact accuracy, always include the original transcript:
// PRF with transcript for context
const prfResponse = await fetch('/api/ai/prf', {
  body: JSON.stringify({
    transcript: fullTranscript,
    systemPrompt: prfPrompt
  })
})

// Hooks with transcript for fact-checking
const hooksResponse = await fetch('/api/ai/hooks', {
  body: JSON.stringify({
    prf: `SOURCE TRANSCRIPT:\n${fullTranscript}\n\n═══...═══\nPRF:\n${prfContent}`,
    systemPrompt: hooksPrompt
  })
})

2. Use RAG for Brand Consistency

Keep useRAG: true (default) to inject brand guidelines:
{
  "useRAG": true,  // Fetches brand voice, writing rules, design patterns
  "ragQuery": "viral hooks for IT leaders"  // Custom query for better context
}

3. Track Generation History

For infographics, pass previous designs to ensure variety:
const history = episode.generatedAssets.map(a => a.spec.layout)

const spec = await generateInfographic({
  history: history,  // ["Doom Loop", "Timeline", "Pyramid"]
  // ... other params
})

4. Validate AI Output

Always validate generated content before saving:
if (!prfContent || prfContent.length < 500) {
  throw new Error('PRF generation failed or too short')
}

if (!spec.prompt || spec.prompt.length < 100) {
  throw new Error('Invalid infographic spec')
}

Build docs developers (and LLMs) love