Skip to content

LLM Integration

instatollm is designed to produce output that's immediately usable as LLM context. This page shows how to combine it with popular LLMs.


Why structured JSON for LLMs

Raw video can't be fed into most LLMs. instatollm converts a Reel into a dense, structured JSON that encodes everything an LLM needs to reason about the content:

  • summary — one-sentence context for the LLM
  • visual.text_on_screen — OCR output: menus, prices, links, brand names
  • audio.transcript — full speech, ready to search or summarize
  • content.key_moments — timeline with timestamps
  • content.hooks — what grabs attention
  • platform_meta — reach, engagement, creator info

With Claude (Anthropic)

import anthropic
import httpx
import time

# 1. Get reel analysis
def get_reel_analysis(url: str, ist_token: str) -> dict:
    headers = {"Authorization": f"Bearer {ist_token}"}
    r = httpx.post(
        "https://api.instatollm.com/api/v1/reels/analyze",
        headers=headers,
        json={"url": url},
    )
    job_id = r.json()["id"]

    for _ in range(24):
        time.sleep(5)
        r = httpx.get(f"https://api.instatollm.com/api/v1/reels/{job_id}", headers=headers)
        data = r.json()
        if data["status"] == "done":
            return data["result"]
        if data["status"] == "error":
            raise RuntimeError(data.get("error"))
    raise TimeoutError()


# 2. Pass to Claude
import json

reel = get_reel_analysis(
    "https://www.instagram.com/reel/DYa0IXPgnP5/",
    ist_token="ist_your_token",
)

client = anthropic.Anthropic()
message = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": f"""Here is a structured analysis of an Instagram Reel:

<reel_analysis>
{json.dumps(reel, indent=2, ensure_ascii=False)}
</reel_analysis>

Based on this analysis:
1. What is the main message of this Reel?
2. What products or places are mentioned (check text_on_screen and transcript)?
3. Who is the target audience?
4. What makes the hook effective?""",
        }
    ],
)
print(message.content[0].text)

With OpenAI (GPT-4o)

from openai import OpenAI
import json

reel = get_reel_analysis("https://www.instagram.com/reel/DYa0IXPgnP5/", "ist_your_token")

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {
            "role": "system",
            "content": "You are a social media analyst. Analyze Instagram Reel data and provide actionable insights.",
        },
        {
            "role": "user",
            "content": f"Reel analysis:\n\n{json.dumps(reel, indent=2)}",
        },
    ],
)
print(response.choices[0].message.content)

Prompt templates

Content summarization

Given this Instagram Reel analysis:
{reel_json}

Write a 2-sentence summary suitable for a newsletter.
Focus on: what happens, who it's for, key takeaway.

OCR extraction

From this Reel analysis, extract all business-relevant information visible on screen:
- Restaurant/venue names
- Prices and menu items  
- URLs and social handles
- Product names and brands
- Location names

Text on screen: {text_on_screen}
Transcript: {transcript}

Viral analysis

Analyze why this Reel might go viral:

Hook (first 3s): {hooks}
Key moments: {key_moments}
Tone: {tone}
Views: {view_count}
Topics: {topics}

Rate viral potential 1-10 and explain the top 3 reasons.

Content calendar

I'm creating a content calendar. Here's a competitor's successful Reel:

Summary: {summary}
Format: {format}
Target audience: {target_audience}  
Tone: {tone}
Hook: {hooks}
CTA: {call_to_action}

Suggest 3 similar content ideas I could create for my own brand.

Batch processing

import asyncio
import httpx
import json

HEADERS = {"Authorization": "Bearer ist_your_token"}

async def analyze_reel(client: httpx.AsyncClient, url: str) -> dict:
    r = await client.post(
        "https://api.instatollm.com/api/v1/reels/analyze",
        json={"url": url},
    )
    job_id = r.json()["id"]

    for _ in range(24):
        await asyncio.sleep(5)
        r = await client.get(f"https://api.instatollm.com/api/v1/reels/{job_id}")
        data = r.json()
        if data["status"] == "done":
            return data["result"]
        if data["status"] == "error":
            raise RuntimeError(data.get("error"))
    raise TimeoutError(f"Timeout for job {job_id}")


async def main():
    urls = [
        "https://www.instagram.com/reel/ABC123/",
        "https://www.instagram.com/reel/DEF456/",
        "https://www.instagram.com/reel/GHI789/",
    ]

    async with httpx.AsyncClient(base_url="https://api.instatollm.com", headers=HEADERS) as client:
        results = await asyncio.gather(*[analyze_reel(client, u) for u in urls])

    for url, result in zip(urls, results):
        print(f"{url}: {result['summary']}")

asyncio.run(main())

n8n / Zapier integration

Use the HTTP Request node with:

  • Method: POST
  • URL: https://api.instatollm.com/api/v1/reels/analyze
  • Header: Authorization: Bearer ist_your_token
  • Body: {"url": "{{ $json.reel_url }}"}

Then poll GET /api/v1/reels/{{ $json.id }} every 10 seconds until status == "done".